布局(1、线性布局)

1、android线性布局最为基础,基本框架如下:

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical" >
    </LinearLayout>

其中 layout_width 和 layout_height 为该线性布局的高、宽;

wrap_content:设置该视图尺寸为能够展示内部全部控件;

match_parent/fill_parent:设置该视图尺寸为填满父视图全部空间;

其中orientation 设置线性布局的方向,及vertical(垂直)和horizantal(水平)

 

2、布局也可利用paddint\margin参数调整位置,如下:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:layout_marginLeft="10dip"
    android:orientation="vertical"
    android:paddingTop="17dip" >

与web中的盒式布局类似,margin代表视图与父视图的边距,而padding代表自身与内部控件的边距

线性布局可采用gravity参数设置内部控件居中,例如:

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:orientation="vertical" 
        android:gravity="center_vertical">

转载于:https://www.cnblogs.com/Fredric-2013/archive/2013/01/23/4107336.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值