Blog purpose for android basic example for android app developer. any query please my contact

Thursday, 22 April 2021

android studio framelayout example

 android studio framelayout example

introduction FrameLayout android example:


Android frame layout with examples. In Android, frame layout is a viewing group used to block a location on the screen to display a single object.


FrameLayout is designed to block a location on the screen to display a single object. In general, FrameLayout should be used to capture a single child view, as it can be difficult to schedule child views in a variety of screen sizes unless the children are distracted.


What is a FrameLayout?

FrameLayout is designed to block out an area on the screen to display a single item. Generally, FrameLayout should be used to hold a single child view, because it can be difficult to organize child views in a way that's scalable to different screen sizes without the children overlapping each other.



1.Open Android Studio Click a New Project :


framelayout android example




2.Click A Empty Activity and Click Next :


framelayout android studio




3.Rename App Name and Package Name And Click Finish:


frame layout in android studio




4.FrameLayout.java:

package com.akash.myapplication;


import androidx.appcompat.app.AppCompatActivity;


import android.os.Bundle;


public class FrameLayout extends AppCompatActivity {


    @Override

    protected void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_frame_layout);

    }

}



5.activity_frame_layout.xml:

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"

    android:layout_width="fill_parent"

    android:layout_height="fill_parent">


    <ImageView

        android:src="@drawable/ic_launcher"

        android:scaleType="fitCenter"

        android:layout_height="250px"

        android:layout_width="250px"/>


    <TextView

        android:text="Frame Layout"

        android:textSize="30px"

        android:textStyle="bold"

        android:layout_height="fill_parent"

        android:layout_width="fill_parent"

        android:gravity="center"/>

</FrameLayout>


6.AndroidManifest.xml:

<?xml version="1.0" encoding="utf-8"?>

<manifest xmlns:android="http://schemas.android.com/apk/res/android"

    package="com.akash.myapplication">


    <application

        android:allowBackup="true"

        android:icon="@mipmap/ic_launcher"

        android:label="@string/app_name"

        android:roundIcon="@mipmap/ic_launcher_round"

        android:supportsRtl="true"

        android:theme="@style/AppTheme">

       

        <activity android:name=".FrameLayout">

            <intent-filter>

                <action android:name="android.intent.action.MAIN" />


                <category android:name="android.intent.category.LAUNCHER" />

            </intent-filter>

        </activity>

    </application>


</manifest>


7.colors.xml:

<?xml version="1.0" encoding="utf-8"?>

<resources>

    <color name="colorPrimary">#6200EE</color>

    <color name="colorPrimaryDark">#3700B3</color>

    <color name="colorAccent">#03DAC5</color>

</resources>


8.strings.xml:

<resources>

    <string name="app_name">android studio framelayout</string>

</resources>


9.output:

android studio framelayout





No comments:

Post a Comment