Android UI布局TableLayout

來源:互聯網
上載者:User

標籤:

瞭解字面上TableLayout一個表格樣式布局。這種布局將包括以行和列的形式的元件被布置。表格列的數目是列的各行中的最大數目。當然,表格裡面的單元格它能夠清空。



執行個體:LayoutDemo
執行效果:


代碼清單:
布局檔案:table_layout.xml

<?

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="1" > <TableRow> <TextView android:gravity="right" android:textStyle="bold" android:padding="3dip" android:text="使用者名稱稱:" /> <EditText android:id="@+id/username" android:padding="3dip" android:scrollHorizontally="true" /> </TableRow> <TableRow> <TextView android:gravity="right" android:textStyle="bold" android:padding="3dip" android:text="使用者密碼:" /> <EditText android:id="@+id/password" android:padding="3dip" android:password="true" /> </TableRow> <TableRow android:gravity="right"> <Button android:id="@+id/cancel" android:text="取消" /> <Button android:id="@+id/login" android:text="登入" /> </TableRow></TableLayout>

在上面的布局代碼中一共同擁有3行,即3個TableRow,每個TableRow裡邊都有兩個單元格。
TableLayout標籤定義了一個表格布局(TableLayout).
TableRow標籤定義了表格布局裡邊的一行。每一行裡邊能夠自由的加入一些組件,比方在上邊我們主要加入了button組件和編輯框組件。

Java源碼檔案:TableLayoutActivity.java
package com.rainsong.layoutdemo;import android.app.Activity;import android.os.Bundle;public class TableLayoutActivity extends Activity{    /** Called when the activity is first created. */    @Override    public void onCreate(Bundle savedInstanceState)    {        super.onCreate(savedInstanceState);        setContentView(R.layout.table_layout);    }}



Android UI布局TableLayout

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.