安卓学习记录-Android-day19-UI学习2

基本布局

作用:放置多个控件的容器,可以嵌套多层布局,完成复杂界面的实现。


LinearLayout 线性布局

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"

    android:id="@+id/container"

    android:layout_width="match_parent"

    android:layout_height="match_parent"

    android:orientation="vertical">    //控件按垂直方向排列,取“horizontal”水平方向依次排列。默认是按照水平方向排列。

</LinearLayout>

注意:控件水平方向放置,不能指定宽度为match_parent。

     同理,垂直放置,不能指定高度为match_parent。

  <TextView

        android:id="@+id/input_message"

        android:layout_width="0dp"

        android:layout_height="wrap_content"

        android:layout_weight="1"

        android:hint="Typesomething"

        />

 

    <Button

        android:id="@+id/send"

        android:layout_width="0dp"

        android:layout_height="wrap_content"

        android:layout_weight="1"

        android:text="Send" />

 

  android:layout_weight="1"//水平方向上平分宽度

也可以修改为其他值,系统会统计界面否认全部值,并根据比例分配界面空间。

RelativeLayout相对布局

 

    <Button

        android:id="@+id/button1"

        android:layout_width="wrap_content"

        android:layout_height="wrap_content"

        android:layout_alignParentTop="true"

        android:layout_marginTop="151dp"

        android:layout_toLeftOf="@+id/button3"

        android:text="Button1"/>

 

    <Button

        android:id="@+id/button2"

        android:layout_width="wrap_content"

        android:layout_height="wrap_content"

        android:layout_alignBaseline="@+id/button1"

        android:layout_alignBottom="@+id/button1"

        android:layout_toRightOf="@+id/button3"

        android:text="Button2" />

FrameLayout:所有的控件都会被放置在左上角。

TableLayout 用表格方式排列控件。     

TableRow 表示行,里面有几个控件就有几列

<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"

    android:layout_width="match_parent"

    android:layout_height="match_parent">

    android:stretchColumns="1"//拉伸第二列

<TableRow >

    <TextView

        android:layout_height="wrap_content"

        android:text="Account:"/>

    <EditText

        android:id="@+id/account"

        android:layout_height="wrap_content"

        android:hint="Input your accunt"

        />

    </TableRow>

                         

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

程序员吾非同

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值