Android学习.1(线性布局和相对布局)
2013-12-02 20:27
507 查看
本文来自我的个人网站,如有兴趣,欢迎访问www.qingshuimonk.com!
1. 线性布局(LinearLayout):在该标签下的所有子元素会根据orientation属性的值来决定是按行或者是按列来逐个显示。代码示例如下:
2. 另外还有相对布局(RelativeLayout),比较简单,这里不再赘述。
3. 在实际中RelativeLayout和LinearLayout一般搭配使用,例如将刚才的代码改变一下:
就有了这样的效果:
4. 表格布局(TableLayout)与html中的表格布局类似,其中TableRow标签代表一个行,而TextView标签代表其中的一个元素。 表格布局和帧布局在初期用的较少,所以以后接触到了再说。
1. 线性布局(LinearLayout):在该标签下的所有子元素会根据orientation属性的值来决定是按行或者是按列来逐个显示。代码示例如下:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" > <Button android:id="@+id/button1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/app_name" /> <Button android:id="@+id/button2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/hello_world" /> <Button android:id="@+id/button3" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/test" /> </LinearLayout>就会产生这样的效果:
2. 另外还有相对布局(RelativeLayout),比较简单,这里不再赘述。
3. 在实际中RelativeLayout和LinearLayout一般搭配使用,例如将刚才的代码改变一下:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" > <Button android:id="@+id/button3" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/test" /> <RelativeLayout android:layout_width="fill_parent" android:layout_height="fill_parent"> <Button android:id="@+id/button2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_toRightOf="@id/button1" android:layout_alignTop="@id/button1" android:text="@string/hello_world" /> <Button android:id="@+id/button1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentLeft="true" android:layout_alignParentTop="true" android:text="@string/app_name" /> </RelativeLayout> </LinearLayout>
就有了这样的效果:
4. 表格布局(TableLayout)与html中的表格布局类似,其中TableRow标签代表一个行,而TextView标签代表其中的一个元素。 表格布局和帧布局在初期用的较少,所以以后接触到了再说。
相关文章推荐
- Android布局学习——线性布局和相对布局混合使用
- 学习android第四周总结相对布局和线性布局常用属性的作用
- Android布局——线性布局、相对布局
- android线性布局__LinearLayout的简单学习
- Android学习系列(二)布局管理器之线性布局的3种实现方式
- Android----------线性布局和相对布局的使用
- Android常用布局(FrameLayout(框架布局)、LinearLayout(线性布局)、RelativeLayout(相对布局))详解
- [Android新手学习笔记18]-LinearLayou线性布局
- Android应用开发学习笔记之相对布局
- Android——excise(用线性布局、表格布局、相对布局做发送邮件界面)
- Android学习-RelativeLayout相对布局属性方法
- Androidx学习笔记(6)--常见布局--线性布局
- Android学习 8-> 相对布局RelativeLayout
- Android学习之线性布局
- android 中的线性布局与相对布局
- Android两大布局:线性布局(LinearLayout) 相对布局(RelativeLayout)
- 相对布局(作业)-- MarsChen Android 开发教程学习笔记
- Android学习(十一)五布局之线性布局
- Android -- UI布局管理,相对布局,线性布局,表格布局,绝对布局,帧布局
- 再学习---Android相对布局(RelativeLayout)