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>
    本博客基于网络课程完成,旨在学习,有错误请指正!
  • 相关阅读:
    关于程序中以时间判断接收数据结束时,接收数据长度设置为1时,出现接收不全的问题解释。
    stm32 外部8M晶振 改为12M的方法
    django iis 部署
    电信NB卡
    socketserver
    APScheduler简介
    三极管开关电路
    mysql授权
    解决VMware无法共享ubuntu虚拟机文件
    Python解析yaml配置文件
  • 原文地址:https://www.cnblogs.com/comefuture/p/6733961.html
Copyright © 2011-2022 走看看