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">

更多相关文章

  1. Android布局文件中的属性含义
  2. Android界面设计之:使用水平视图切换
  3. Android 相对布局 RelativeLayout 属性
  4. Android布局优化(三)使用AsyncLayoutInflater异步加载布局
  5. Android布局之xml设置
  6. Android UI布局之区分 android:gravity 和 android:layout_gravi

随机推荐

  1. Android(安卓)图像处理(类型转换,比例缩放,
  2. Android(安卓)引用库项目,Debug 库项目
  3. android 实现按钮旋转720°
  4. Android(安卓)– 自定义Loading圆点
  5. 【Android病毒分析报告】 - Obad
  6. Android:如何设计一个完全不可见的Activi
  7. Android(安卓)错误案例
  8. Android(安卓)review Android中的测试
  9. Android内容提供者源码
  10. Android(安卓)中WebView 视频自动播放