android线性布局和基本控件属性

线性布局:LinearLayout

跟节点

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

</LinearLayout>

跟属性android:orientation="horizontal" android:orientation="vertical" 水平还是垂直分布。水平分布,每个控件占用一列。垂直分布,每个控件占用一行。

android:layout_width android:layout_height 宽/高设置,match_parent/fill_parent 充满父容器,wrap_content由内容决定,刚好放下内部控件。

控件基本属性:

android:id="@+id/text" 控件id

android:text="@string/hello_world" 文本内容

android:gravity="center_vertical" 位置(居中、居左、居右) 非控件放置位置,而是控件内部(文字)位置

android:textSize="32pt" 字体大小

android:background="#aa0000" 背景色

android:textColor="#0000FF"; 字体颜色

android:layout_width="match_parent" android:layout_height="wrap_content" 控件水平垂直大小

android:paddingLeft="10dip"

android:paddingTop="10dip"

android:paddingRight="10dip"

android:paddingBottom="10dip"

内部边距

android:layout_weight="1" 多个控件的所占面积的比例,注layout必须充满父容器,不然此处无效

android:singleLine="true" 内容再多也只显示一行 false则自动换行

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值