Android table layout (similar to HTML)

Source: Internet
Author: User

<?xml version="1.0"encoding="Utf-8"? ><linearlayout xmlns:android="http://schemas.android.com/apk/res/android"android:orientation="Vertical"Android:layout_width="fill_parent"Android:layout_height="fill_parent"><!--define the first table layout, specify that the 2nd column is allowed to shrink, and the 3rd column allows stretching--><tablelayout android:id="@+id/tablelayout01"Android:layout_width="fill_parent"Android:layout_height="wrap_content"Android:shrinkcolumns="1"Android:stretchcolumns="2"> <!--directly add a button, it will take up one line--<button android:id="@+id/ok1"Android:layout_width="wrap_content"Android:layout_height="wrap_content"Android:text="buttons on a single line"/> <!--Add a table row--<TableRow> <!--add 3 buttons to the table row--<button android:id="@+id/ok2"Android:layout_width="wrap_content"Android:layout_height="wrap_content"Android:text="Normal button"/> <button android:id="@+id/ok3"Android:layout_width="wrap_content"Android:layout_height="wrap_content"Android:text="allow the button to be shrunk"/> <button android:id="@+id/ok4"Android:layout_width="wrap_content"Android:layout_height="wrap_content"Android:text="Allow stretched buttons"/> </TableRow> </TableLayout><!--define the second table layout and specify the second column to hide--><tablelayout android:id="@+id/tablelayout01"Android:layout_width="fill_parent"Android:layout_height="wrap_content"Android:collapsecolumns="1"><!--Add a button directly, it will take up a line--><button android:id="@+id/ok5"Android:layout_width="wrap_content"Android:layout_height="wrap_content"Android:text="buttons on a single line"/><!--Define a table row--><tablerow><!--add 3 buttons to the table row--><button android:id="@+id/ok6"Android:layout_width="wrap_content"Android:layout_height="wrap_content"Android:text="Normal button 1"/> <button android:id="@+id/ok7"Android:layout_width="wrap_content"Android:layout_height="wrap_content"Android:text="the button that is hidden"/> <button android:id="@+id/ok8"Android:layout_width="wrap_content"Android:layout_height="wrap_content"Android:text="Normal button 3"/></tablerow> </TableLayout><!--Define a third table layout, specifying that 2nd, 32 columns can be stretched--><tablelayout android:id="@+id/tablelayout01"Android:layout_width="fill_parent"Android:layout_height="wrap_content"Android:stretchcolumns=" the"><!--Add a button directly, it will take up a line--><button android:id="@+id/ok9"Android:layout_width="wrap_content"Android:layout_height="wrap_content"Android:text="buttons on a single line"/><!--Define a table row--><tablerow><!--add 3 buttons to the table row--><button android:id="@+id/ok10"Android:layout_width="wrap_content"Android:layout_height="wrap_content"Android:text="Normal button"/> <button android:id="@+id/ok11"Android:layout_width="wrap_content"Android:layout_height="wrap_content"Android:text="Allow stretched buttons"/> <button android:id="@+id/ok12"Android:layout_width="wrap_content"Android:layout_height="wrap_content"Android:text="Allow stretched buttons"/></tablerow> <!--define a table row--><tablerow><!--add 2 buttons to the table row--><button android:id="@+id/ok13"Android:layout_width="wrap_content"Android:layout_height="wrap_content"Android:text="Normal button"/> <button android:id="@+id/ok14"Android:layout_width="wrap_content"Android:layout_height="wrap_content"Android:text="Allow stretched buttons"/></tablerow> </TableLayout></LinearLayout>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.