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 :
2.Click A Empty Activity and Click Next :
3.Rename App Name and Package Name And Click Finish:
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>
No comments:
Post a Comment