zoukankan      html  css  js  c++  java
  • android的帧布局和表格布局

    1.帧布局

    特点:所有的元素都会置于视图的左上角,并且,后续元素会覆盖前面的元素。

    layout代码实例:

     1 <?xml version="1.0" encoding="utf-8"?>
     2 <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
     3     android:layout_width="match_parent"
     4     android:layout_height="match_parent" >
     5 
     6     <TextView
     7         android:layout_gravity="center"              //上下左右居中
     8         android:id="@+id/textView1"
     9         android:layout_width="200dp"
    10         android:layout_height="200dp"
    11         android:text="第一个页面" 
    12         android:background="#123456"/>
    13 
    14     <TextView
    15         android:layout_gravity="center"
    16         android:id="@+id/textView2"
    17         android:layout_width="150dp"
    18         android:layout_height="150dp"
    19         android:text="第二个页面"
    20         android:background="#321456" />
    21 
    22     <TextView
    23         android:layout_gravity="center"
    24         android:id="@+id/textView3"
    25         android:layout_width="100dp"
    26         android:layout_height="100dp"
    27         android:text="第三个页面" 
    28         android:background="#345254"/>
    29 
    30     <TextView
    31         android:layout_gravity="center"
    32         android:id="@+id/textView4"
    33         android:layout_width="50dp"
    34         android:layout_height="50dp"
    35         android:text="第四个页面" 
    36         android:background="#573452"/>
    37 
    38 </FrameLayout>

    2.表格布局

    TableLayout采用表格的形式管理控件,每一行为一个TableRow对象

    1.全局属性

    android:collapseColumns=“”                  ----列

    android:shrinkColumns=“”                     -----排版收缩

    android:  stretchColumns-“”                   ------排版扩张

    2.局部属性

    android:layout_columns=""                      ------显示在某列

    android:layout_span=“ ”                         --------占用几列

    3.实例

    <?xml version="1.0" encoding="utf-8"?>
    <TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent" 
    
        android:stretchColumns="*"                
        >
    
        <TableRow
            android:id="@+id/tableRow1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" >
    
            <Button
                android:layout_column="1"                               
                android:layout_span="2"                                 
                android:id="@+id/button1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="1" />
    
            <Button
                android:id="@+id/button2"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="2" />
    
            <Button
                android:id="@+id/button3"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="3" />
    
        </TableRow>
    
        <TableRow
            android:id="@+id/tableRow2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" >
    
            <Button
                android:id="@+id/button4"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="4" />
    
            <Button
                android:id="@+id/button5"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="5" />
    
            <Button
                android:id="@+id/button6"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="6" />
    
        </TableRow>
    
    </TableLayout>
    本博客基于网络课程完成,旨在学习,有错误请指正!
  • 相关阅读:
    UVa 11384 Help is needed for Dexter (递归)
    HDU 4355 Party All the Time (三分求极值)
    UVa 11992 Fast Matrix Operations (线段树,区间修改)
    LA 3708 && POJ 3154 Graveyard (思维)
    LA 3942 && UVa 1401 Remember the Word (Trie + DP)
    LA 4329 Ping pong (树状数组)
    HDU 2058 The sum problem (数学+暴力)
    POJ 1458 Common Subsequence (DP+LCS,最长公共子序列)
    代理服务器
    .net垃圾回收
  • 原文地址:https://www.cnblogs.com/comefuture/p/6733961.html
Copyright © 2011-2022 走看看