Android Development notes (3) -- GridLayout, androidgridlayout

Source: Internet
Author: User

Android Development notes (3) -- GridLayout, androidgridlayout

 

GirdLayout calculator example and detailed notes: http://www.cnblogs.com/skywang12345/p/3154150.html

 

Grid layout:Make the components in the container form a grid distribution of M rows × N columns.

It is the same as Relative Layout \ Linear Layout and belongs to the ViewGroup type.

 

Layout setting procedure

1. Set the maximum row and column Value

android:columnCount=“5”android:rowCount=“6”

2. Set the data input sequence

android:orientation

 

3. Set row and column Weights

android:layout_columnWeightandroid:layout_rowWeight

4. Set cross-row and column

android:layout_columnSpan="2"

 

Example:

Basketball scoring app, which records each score table

 1 <GridLayout xmlns:android="http://schemas.android.com/apk/res/android" 2     android:layout_width="match_parent" 3     android:layout_height="wrap_content" 4     android:orientation="horizontal" 5     android:columnCount="6" 6     android:rowCount="3"> 7     <TextView 8         android:text="Table" 9         style="@style/table_layout"/>10     <TextView11         android:text="1st"12         style="@style/table_layout"/>13     <TextView14         android:text="2nd"15         style="@style/table_layout"/>16     <TextView17         android:text="3rd"18         style="@style/table_layout"/>19     <TextView20         android:text="4th"21         style="@style/table_layout"/>22     <TextView23         android:text="TOTAL"24         style="@style/table_layout"/>25     <TextView26         android:text="A"27         style="@style/table_layout"/>28     <TextView29         android:text="0"30         android:id="@+id/score_a_part1"31         style="@style/table_layout"/>32     <TextView33         android:text="0"34         android:id="@+id/score_a_part2"35         style="@style/table_layout"/>36     <TextView37         android:text="0"38         android:id="@+id/score_a_part3"39         style="@style/table_layout"/>40     <TextView41         android:text="0"42         android:id="@+id/score_a_part4"43         style="@style/table_layout"/>44     <TextView45         android:text="0"46         android:id="@+id/score_a_total"47         style="@style/table_layout"/>48     <TextView49         android:text="B"50         style="@style/table_layout"/>51     <TextView52         android:text="0"53         android:id="@+id/score_b_part1"54         style="@style/table_layout"/>55     <TextView56         android:text="0"57         android:id="@+id/score_b_part2"58         style="@style/table_layout"/>59     <TextView60         android:text="0"61         android:id="@+id/score_b_part3"62         style="@style/table_layout"/>63     <TextView64         android:text="0"65         android:id="@+id/score_b_part4"66         style="@style/table_layout"/>67     <TextView68         android:text="0"69         android:id="@+id/score_b_total"70         style="@style/table_layout"/>71     </GridLayout>

 

Display Effect:

 

 

 

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.