GridLayout Grid layout of Android layout _android

Source: Internet
Author: User

The Grid layout label is GridLayout. This layout is a new layout for android4.0. This layout is only available after 4.0 versions.

But some new stuff.

① like LinearLayout (linear layout), he can set the alignment of a component in a container

Components in a ② container can span multiple rows or across multiple columns (compared to tablelayout, which takes up a single line of components)

Because it's Android 4.0 new, API level 14, in this version of the previous SDK

You need to import the project, and then we'll explain it in detail.

Common Properties:

Arrange alignment:

① sets the arrangement of the components: android:orientation= "" Vertical (vertical, default) or horizontal (horizontal)

② set the alignment of the component: android:layout_gravity= "" Center,left,right,buttom, these, if you want to use two words at the same time: Eg:buttom|left

Learning Guide Map

(i) Introduction

The grid layout is represented by GridLayout, the newly added layout manager after android4.0, and therefore needs to be used after the android4.0 version, if the layout manager is used on an earlier platform, you need to import the appropriate support library < Android.support.v7.widget.gridlayout>

(ii)----Calculator in the list of cases

<?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:rowcount=" 6 "Android:col Umncount= "4" android:layout_gravity= "Fill" > <textview android:layout_width= "match_parent" android:layout _height= "wrap_content" android:text= "0" android:textsize= "80sp" android:layout_marginright= "5DP" android:l ayout_marginleft= "5DP" android:layout_columnspan= "4" android:background= "#eee" android:padding= "3SP" Andro Id:editable= "false" android:textcolor= "#000"/> <button android:layout_width= "Match_parent" android:l ayout_height= "Wrap_content" android:layout_columnspan= "4" android:text= "clear" android:textcolor= "#000" android:t Extsize= "24DP" android:layout_marginleft= "5DP" android:layout_marginright= "5DP" android:background= "@android: Colo R/background_light "/> &LT Button android:layout_margintop= "20DP" android:layout_width= "wrap_content" android:layout_height= "wrap_content "android:text=" 7 "android:textcolor=" #000 "android:textsize=" 24DP "android:layout_marginleft=" 5DP "an droid:layout_marginright= "5DP" android:background= "@android: Color/background_light"/> <button Android : layout_margintop= "20DP" android:layout_width= "wrap_content" android:layout_height= "Wrap_content" Android:text = "8" android:textcolor= "#000" android:textsize= "24DP" android:layout_marginleft= "10DP" android:background= "@android: Color/background_light"/> <button android:layout_margintop= "20DP" android:layout_width= "Wra P_content "android:layout_height=" Wrap_content "android:text=" 9 "android:textcolor=" #000 "android:textsize = "24DP" android:layout_marginleft= "10DP" android:background= "@android: Color/background_light"/> <butt On Android:layout_margintop= "20DP" android:layout_width= "wrap_content" android:layout_height= "wrap_content" android:text= "+" Android:textcolor= "#000" android:textsize= "24DP" android:layout_marginleft= "10DP" android:background= "@androi D:color/background_light "/> <button android:layout_margintop=" 20DP "android:layout_width=" Wrap_conten
    T "android:layout_height=" Wrap_content "android:text=" 4 "android:textcolor=" #000 "android:textsize=" 24DP " android:layout_marginleft= "5DP" android:layout_marginright= "5DP" android:background= "@android: Color/background _light "/> <button android:layout_margintop=" 20DP "android:layout_width=" Wrap_content "Android:lay" out_height= "Wrap_content" android:text= "5" android:textcolor= "#000" android:textsize= "24DP" android:layout _marginleft= "10DP" android:background= "@android: Color/background_light"/> <button android:layout_marg intop= "20DP" Android: layout_width= "wrap_content" android:layout_height= "Wrap_content" android:text= "6" android:textcolor= "#000"
    Android:textsize= "24DP" android:layout_marginleft= "10DP" android:background= "@android: Color/background_light" /> <button android:layout_margintop= "20DP" android:layout_width= "Wrap_content" android:layout_height = "Wrap_content" android:text= "-" android:textcolor= "#000" android:textsize= "24DP" Android:layout_marginlef t= "10DP" android:background= "@android: Color/background_light"/> <button android:layout_margintop= "20d P "android:layout_width=" Wrap_content "android:layout_height=" Wrap_content "android:text=" 1 "Android:textC Olor= "#000" android:textsize= "24DP" android:layout_marginleft= "5DP" android:layout_marginright= "5DP" Andro Id:background= "@android: Color/background_light"/> <button android:layout_margintop= "20DP" Android:lay Out_width= "Wrap_content"
    android:layout_height= "Wrap_content" android:text= "2" android:textcolor= "#000" android:textsize= "24DP" android:layout_marginleft= "10DP" android:background= "@android: Color/background_light"/> <button and roid:layout_margintop= "20DP" android:layout_width= "wrap_content" android:layout_height= "Wrap_content" Android: text= "3" android:textcolor= "#000" android:textsize= "24DP" android:layout_marginleft= "10DP" Android:backgro Und= "@android: Color/background_light"/> <button android:layout_margintop= "20DP" android:layout_width= "Wrap_content" android:layout_height= "wrap_content" android:text= "*" android:textcolor= "#000" Android:text Size= "24DP" android:layout_marginleft= "10DP" android:background= "@android: Color/background_light"/> < Button android:layout_margintop= "20DP" android:layout_width= "wrap_content" android:layout_height= "wrap_content
 "Android:text=". "   Android:textcolor= "#000" android:textsize= "24DP" android:layout_marginleft= "5DP" android:layout_marginright 
    = "5DP" android:background= "@android: Color/background_light"/> <button android:layout_margintop= "20DP" Android:layout_width= "Wrap_content" android:layout_height= "wrap_content" android:text= "0" Android:textCol Or= "#000" android:textsize= "24DP" android:layout_marginleft= "10DP" android:background= "@android: Color/backgrou Nd_light "/> <button android:layout_margintop=" 20DP "android:layout_width=" Wrap_content "Android:l" ayout_height= "Wrap_content" android:text= "=" android:textcolor= "#000" android:textsize= "24DP" Android:layo ut_marginleft= "10DP" android:background= "@android: Color/background_light"/> <button android:layout_ma rgintop= "20DP" android:layout_width= "wrap_content" android:layout_height= "wrap_content" android:text= "/" a
Ndroid:textcolor= "#000"    Android:textsize= "24DP" android:layout_marginleft= "10DP" android:background= "@android: Color/background_light" /> </GridLayout>

The above content is small series to introduce the Android layout of the GridLayout grid layout related knowledge, I hope you like.

Related Article

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.