"Turn" Pro Android Learning Note (28): User interface and Control (+): GridLayout

Source: Internet
Author: User

Grid layout: GridLayout

I personally feel that the design of GridLayout is not very perfect, each grid size, determined by the filling of the cell, that is, the default is wrap is easy for the entire gridlayout beyond the screen. Here is an example:

<?xml version= "1.0" encoding= "Utf-8"?>
<gridlayout xmlns:android= "Http://schemas.android.com/apk/res/android"
Android:layout_width= "Match_parent"
android:layout_height= "Match_parent"
android:orientation= "Vertical"
Android:RowCount= "4"
Android:ColumnCount= "2" > <!--Design 4x2 table--
<imageviewandroid:layout_row= "0"
android:layout_column= "1"
Android:scaletype= "Fitcenter"
android:src= "@drawable/png02"/> <!--you can specify where to place-
<imageviewandroid:layout_row= "1"
android:layout_column= "0"
Android:scaletype= "Fitcenter"
android:src= "@drawable/png04"/>
<imageviewandroid:layout_row= "2"
android:layout_column= "1"

Android:scaletype= "Fitcenter"
android:src= "@drawable/png08"/>
<imageviewandroid:layout_row= "3"
android:layout_column= "0"
Android:scaletype= "Fitcenter"
android:src= "@drawable/png18"/>
</GridLayout>

The flexible expense of gridlayout is that you can specify the location of the view mode and run some issues without placing content, such as the example above. Both the line number and the column number are calculated starting at 0. In addition, if a cell needs to occupy multiple locations, it can be set using Android:layout_rowspan and Android:layout_columnspan.

The biggest problem with GridLayout is that the space occupied by the entire table is indeterminate, and the line spacing is determined by the height of the largest cell in the row, which is determined by the cell with the widest range of columns. In the above example, some of the controls are outside the screen. The size of each cell defaults to wrap_content, and if we set it to match_parent, the size of the cell is the full screen.

RELATED Links: My Android development related articles

"Turn" Pro Android Learning Note (28): User interface and Control (+): GridLayout

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.