您的位置:首页 > 移动开发 > Android开发

Android自学笔记之 Android五大布局之线性布局的功能、常用属性、用法

2015-09-01 06:16 441 查看
1.介绍:

线性布局管理器对存放其中的控件或布局采用线性方式管理

2.LinearLayout的常用属性

android:orientation = “vertical” —— 该属性决定它子类控件的排布方式(vertical:垂直;horizontal:水平)

android:gravity = “center” —— 该属性决定它子类控件的xy的位置

常用属性值

center_vertical:垂直(Y轴)居中

center_horizontal:水平(X轴)居中

center:垂直水平都居中

right/left/buttom:子类控件位于当前布局的右/左/下面

android:layout_gravity----当前控件本身和父控件的位置

android:gravity --- 当前控件的子控件在父控件的位置

!布局里是可以套用布局的

gravity属性:决定它子类的xy位置

gravity属性可以多个连用,用|隔开

3.用法

<span style="font-family:KaiTi_GB2312;"><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:layout_width="match_parent"
    
    android:layout_height="match_parent">

    <Button
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="第一个Button按钮"
        android:id="@+id/button_first" />

    <Button
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="第二个Button按钮"
        android:id="@+id/button2"
        android:layout_gravity="center_horizontal" />

    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="实现跳转页面功能"
        android:id="@+id/textView"
        android:layout_gravity="center_horizontal" />
</LinearLayout></span>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: