歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux編程 >> Linux編程 >> Android中的布局方式之 框架布局管理器

Android中的布局方式之 框架布局管理器

日期:2017/3/1 10:48:45   编辑:Linux編程
FrameLayout 布局,又叫幀布局,就是在屏幕上開辟一個區域以填充所有的組件,但是FrameLayout會將所有的組件都放在屏幕的左上角,而且所有的組件通過層疊的方式來進行顯示,也就是說,他們都是從從上角處開始放,然後一個覆蓋著一個的方式。

看看xml文件,我們只是把Linelayout換成了Framelayout其它都沒變。如下:

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <FrameLayout xmlns:Android="http://schemas.android.com/apk/res/android"
  3. android:orientation="vertical"
  4. android:layout_width="fill_parent"
  5. android:layout_height="fill_parent"
  6. >
  7. <ImageView
  8. android:id="@+id/myimg"
  9. android:src="@drawable/mldn_3g"
  10. android:layout_width="wrap_content"
  11. android:layout_height="wrap_content"/>
  12. <EditText
  13. android:id="@+id/myinput"
  14. android:text="請輸入您的姓名..."
  15. android:layout_width="wrap_content"
  16. android:layout_height="wrap_content"/>
  17. <Button
  18. android:id="@+id/mybut"
  19. android:layout_width="wrap_content"
  20. android:layout_height="wrap_content"
  21. android:text="按我" />
  22. <TextView
  23. android:layout_width="fill_parent"
  24. android:layout_height="wrap_content"
  25. android:text="@string/hello"
  26. />
  27. </FrameLayout>
結果如下:

Copyright © Linux教程網 All Rights Reserved