帧布局

来源:互联网 发布:linux 复制整行 编辑:程序博客网 时间:2024/05/21 15:49

帧布局由FrameLayout所代表,帧布局容器为每个加入其中的组件创建一个空白的区域(成为一帧),所有每个子组件占据一帧,这些帧都会根据gravity属性执行自动对齐。也就是说,把组件一个一个的叠加在一起。


FrameLayout的常用XML属性及相关方法的说明


XML属性相关方法说明android:foregroundsetForeground(Drawable)

设置该帧布局容器的前景图像

android:foregroundGravity


1.<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"2. android:orientation="vertical"3. android:layout_width="fill_parent"4. android:layout_height="fill_parent">5.<!-- 一次定义7个Textview,先定义的TextView位于底层,后定义的TextView位于上层 -->6.<TextView android:id="@+id/view01"7. android:layout_width="wrap_content"8. android:layout_height="wrap_content"9. android:width="210px"10. android:height="50px"11. android:background="#ff0000"/>12.13.<TextView android:id="@+id/view02"14. android:layout_width="wrap_content"15. android:layout_height="wrap_content"16. android:width="180px"17. android:height="50px"18. android:background="#dd0000"/>19.20.<TextView android:id="@+id/view03"21. android:layout_width="wrap_content"22. android:layout_height="wrap_content"23. android:width="150px"24. android:height="50px"25. android:background="#bb0000"/>26.27.<TextView android:id="@+id/view04"28. android:layout_width="wrap_content"29. android:layout_height="wrap_content"30. android:width="120px"31. android:height="50px"32. android:background="#990000"/>33.34.35.<TextView android:id="@+id/view05"36. android:layout_width="wrap_content"37. android:layout_height="wrap_content"38. android:width="90px"39. android:height="50px"40. android:background="#770000"/>41.42.<TextView android:id="@+id/view06"43. android:layout_width="wrap_content"44. android:layout_height="wrap_content"45. android:width="60px"46. android:height="50px"47. android:background="#550000"/>48.49.<TextView android:id="@+id/view07"50. android:layout_width="wrap_content"51. android:layout_height="wrap_content"52. android:width="30px"53. android:height="50px"54. android:background="#330000"/>55.</FrameLayout>

效果图:


0 0
原创粉丝点击