User Interface with XML
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. However you can add multiple children items to FrameLayout and control their positions within FrameLayout by assigning them gravity. using the "android:layout_gravity" attribute.
Example: Create new Project
activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:orientation="vertical" >
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/imageView"
android:src="@drawable/profile"
android:layout_gravity="left|top" />
<ImageButton
android:layout_width="80dp"
android:layout_height="80dp"
android:id="@+id/imageButton" android:src="@drawable/abc_ic_ab_back_mtrl_am_alpha" android:layout_gravity="center|bottom" />
</FrameLayout>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:orientation="vertical" >
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/imageView"
android:src="@drawable/profile"
android:layout_gravity="left|top" />
<ImageButton
android:layout_width="80dp"
android:layout_height="80dp"
android:id="@+id/imageButton" android:src="@drawable/abc_ic_ab_back_mtrl_am_alpha" android:layout_gravity="center|bottom" />
</FrameLayout>
No comments:
Post a Comment