[Android新手学习笔记20]-FrameLayout帧布局

来源:互联网 发布:心事谁人知谐音 编辑:程序博客网 时间:2024/05/23 01:13

应用场景较少,碎片会使用。

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
  3.    android:layout_width="match_parent"
  4.    android:layout_height="match_parent">
  5.    <Button
  6.        android:id="@+id/button1"
  7.        android:text="Button"
  8.        android:textAllCaps="false"
  9.        android:layout_width="wrap_content"
  10.        android:layout_height="wrap_content" />
  11.    <TextView
  12.        android:id="@+id/text_view"
  13.        android:text="TextView很长很长"
  14.        android:layout_width="wrap_content"
  15.        android:layout_height="wrap_content" />
  16. </FrameLayout>

这种布局会重叠在左上角摆放。可以通过android:layout_gravity来控制对齐。

0 0