應用場景較少,碎片會使用。
- <?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">
-
- <Button
- android:id="@+id/button1"
- android:text="Button"
- android:textAllCaps="false"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content" />
-
- <TextView
- android:id="@+id/text_view"
- android:text="TextView很長很長"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content" />
-
- </FrameLayout>
這種布局會重疊在左上角擺放。可以通過android:layout_gravity來控制對齊。