Android第十课;线性布局
来源:互联网 发布:华为网络交换机的作用 编辑:程序博客网 时间:2024/05/22 08:17
preview
LinearLayout是线性布局控件,它包含的子控件将以横向或竖向的方式排列
常用属性:
android:orientation=”“——该属性决定它子类控件的排布方式(vertical-垂直;horizontal-水平)
android:gravity=”“————–该属性决定它子类的xy的位置:
center_vertical————垂直(Y轴)居中
center_horizontal———垂直(X轴)居中
center————————水平垂直都居中
right————————–子类控件位于当前布局的右边
left—————————子类控件位于当前布局的左边
bottom———————–子类控件位于当前布局的下面
android:layout_gravity=”“———–表示本身在当前父容器的XY的一个位置
layout_gravity是想在父布局里面改变位置的时候用的,gravity是想改变自己内部东西位置是用的android:gravity属性是对该view中内容的限定.比如一个button 上面的text. 你可以设置该text在button内的位置.android:layout_gravity是用来设置该view相对与父view 的位置.比如一个button 在linearlayout里,你想把该button放在linearlayout里靠左、靠右等位置就可以通过该属性设置.
android:layout_weight=”“———–指本身控件占当前父容器的一个比例
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <Button android:text="Button" android:layout_gravity="bottom" android:layout_width="match_parent" android:layout_height="wrap_content" android:id="@+id/button" android:layout_weight="2" /> <Button android:text="Button" android:layout_gravity="bottom" android:layout_width="match_parent" android:layout_height="wrap_content" android:id="@+id/button1" android:layout_weight="1" /></LinearLayout>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <Button android:text="Button" android:layout_gravity="bottom" android:layout_width="match_parent" android:layout_height="match_parent" android:id="@+id/button" android:layout_weight="2" /> <Button android:text="Button" android:layout_gravity="bottom" android:layout_width="match_parent" android:layout_height="match_parent" android:id="@+id/button1" android:layout_weight="1" /></LinearLayout>
这两个xml文件里面唯一区别就是一个是android:layout_height=”wrap_content”,一个是android:layout_height=”match_parent”,wrap_content
会使比例正常显示,而match_parent则会反转
exercise
无
0 0
- Android第十课;线性布局
- android布局之线性布局
- android布局之线性布局
- Android布局之线性布局
- Android布局之线性布局
- android 布局学习---线性布局
- android布局之线性布局
- Android布局之线性布局
- Android 布局LinearLayout(线性布局)
- Android 线性布局详解
- Android线性布局
- Android 线性布局:LinearLayout
- android 线性布局
- Android线性布局
- android线性布局
- android界面线性布局
- Android 线性布局详解
- Android线性布局自适应
- Java集合框架——Map
- PYTHON的TIME模块
- 第55篇铅笔三个按钮自动出来处理(一)
- Spring MVC 中,自动加载 JSON 转换器
- 常用的英语学习网站(持续更新中)
- Android第十课;线性布局
- 面试笔试真题(1)
- swift 之UIWebView
- 微软云计算随笔1-批量为虚拟机添加IP地址描述
- 《Java多线程编程核心技术》---Thread用run( )启动和用start( )区别
- 计算广告系列篇(6)------推荐
- 单链表源码二
- 玩转AppBarLayout,更酷炫的顶部栏
- 使用MERGE方便快捷地更新数据表