应用场景较少,碎片会使用。
<?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来控制对齐。