android布局之Linearlayout(线性布局)
来源:互联网 发布:c语言实战项目开发 编辑:程序博客网 时间:2024/06/06 03:28
android布局中的Linearlayout(线性布局)布局是较为常见的一种布局,正如它的名字,在此布局里的控件将按照线性排布,要么横向,要么垂直。文字的说明太难理解,还是看看实际代码吧:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/activity_main2" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="horizontal" tools:context="com.example.myche.Main2Activity"> <Button android:text="1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/button2" android:layout_weight="1" /> <Button android:text="2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/button3" android:layout_weight="1" /> <Button android:text="3" android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/button" android:layout_weight="1" /></LinearLayout>
这便是一个线性布局了,我在这个布局里放了三个按钮,用来看出它的布局效果,布局大小不用了说了,这里最为重要的一个属性,那就是 android:orientation,这个属性用来指定这个布局是横向还是垂直, android:orientation="horizontal"这个属性便表示布局为横向:
而当我们把这个属性改为 android:orientation="vertical"时,它便成立垂直排列:
以上两种便是其核心了,而根据你所要的效果,你可以在垂直的线性布局中嵌套横向的线性布局来实现诸如九宫格的布局,等等,靠灵活的组合可以做出各式各样的显示效果
阅读全文
0 0
- Android布局之LinearLayout(线性布局)
- Android布局之LinearLayout(线性布局)
- Android布局之LinearLayout(线性布局)
- android布局之Linearlayout(线性布局)
- Android UI之LinearLayout(线性布局)
- Android之LinearLayout线性布局
- 【Android】界面布局之 LinearLayout(线性布局)
- android布局之线性布局(LinearLayout)
- 1.Android之布局LinearLayout(线性布局)
- (一)Android布局之线性布局(LinearLayout)
- android布局之线性布局LinearLayout(总结)
- Android--LinearLayout(线性布局)
- Android LinearLayout(线性布局)
- Android-线性布局(LinearLayout)
- Android:控件布局(线性布局)LinearLayout
- Android 布局LinearLayout(线性布局)
- Android 线性布局:LinearLayout
- Android:线性布局LinearLayout
- JSP四大域对象
- redis执行lua脚本
- 时间序列预测全攻略(附带Python代码)
- 使用JS写一个文字滚动效果
- K&R 6.3 结构数组与结构指针
- android布局之Linearlayout(线性布局)
- Android模拟返回Back操作
- AVL树的插入操作(旋转)图解
- 周志华《Machine Learning》学习笔记(14)--计算学习理论
- php基于ob_start(ob_gzhandler)实现网页压缩功能的方法
- ActiveMQ( 消息队列)
- 使用PHP中的递归思想求出斐波那契数列
- android studio 3.0 更新套路
- Poj2352-树状数组或线段树