• 界面排版-TableLayout的stretchColumns方法


    1.先把XML內的預設RelativeLayout排版方式清空,在去Layout區拉一個TableLayout的到表單上,XML下會出現下面程式碼
     
        <TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:stretchColumns="2"
        >  (android:stretchColumns="2"是設定 TableLayout所有行的第二列是擴展列,列是指上下,行是左右,假設每行都有三列(三個物件),剩下空間會由第二列補齊,下面會做示範)
     
        </TableLayout>
     
    2.在Layout拉一個TableRow出來,在TableLayout標籤之間會夾著TableRow
     
        <TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:stretchColumns="2"
        >
     
            <TableRow
                android:id="@+id/tableRow1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content" >
            </TableRow>
     
        </TableLayout>
     
     
    3.在去widget拉一個物件button出來,如圖片
    接下來再拉一個button
    OK,還是沒變化因為android:stretchColumns="2"是設定第二列才開始填滿,好!在拉一次button
    我們發現真的在第二列開始填滿剩下的空間了!也就是剩下空間會由第二列補齊(最左邊是第0列,以此類推)
  • 相关阅读:
    Longest Substring Without Repeating Characters
    Longest Valid Parentheses
    LInux下编译发生的libc相关错误
    【转载】字符编码笔记:ASCII,Unicode和UTF-8
    Python深入:super函数
    Python基础:常用函数
    25最小操作数问题
    24字符串最短编辑距离
    23最大乘积子串
    22倒排索引简介
  • 原文地址:https://www.cnblogs.com/yxnchinahlj/p/4618636.html
Copyright © 2020-2023  润新知