布局的基本属性和表格布局

来源:互联网 发布:软件中举报是什么意思 编辑:程序博客网 时间:2024/06/10 04:09


布局的基本属性:
android:layout_width     设置控件所占的高度
android:layout_height    设置控件所占的高度
android:layout_marginTop 当前视图上边缘到某条基线的距离
android:layout_marginButton   当前视图下边缘到某条基线的距离
android:gravity   这个是针对控件里的元素来说的,用来控制元素在该控件里显示的位置。
android:layout_gravity   这个是针对控件本身而言,用来控制该控件在包含该控件的父控件中的位置。


LinearLayout线性布局
android:orientation  设置排列方向(horizontal水平排列 | vertical 垂直排列)
android:gravity      设置组件的对齐方式




TableLayout表格布局:表格布局将视图按行,列进行排列,直接向TableLayout中添加控件,则这个控件将占一行,一个表格布局由<TableLayout>标签和若干个<TableRow>标签组成
基本属性:
android:shrinkColumns   某列被拉收缩保证表格能完全填充父容器的宽度
android:stretchColumns  某列被拉伸以保证表格能完全填充父容器的宽度
android:collapseColumns 某列被隐藏
android:layout_span     表示跨列


<TableLayout
        android:layout_width="300dp"
        android:layout_height="wrap_content"
        android:collapseColumns="2"
        >
        
     
    <TableRow>
        <TextView 
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/table5" 
         android:background="#ff0000"
        />
         <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/table6"
         android:background="#0000ff"/>
       
        
         <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/table6"
         android:background="#00ffff"/>
        
    </TableRow>
     <TableRow>
        <TextView 
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/table7" 
         android:background="#ff0000"
        />
         <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/table7"
         android:background="#0000ff"/>
       
        
         <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/table8"
         android:background="#00ffff"/>
        
    </TableRow>
     
    </TableLayout>
原创粉丝点击