Android之GridLayout網格布局

來源:互聯網
上載者:User

標籤:設定   div   1.0   回退   wrap   對齊   height   fill   out   

1、相關屬性

  GridLayout網格布局是4.0之後引入的布局方式!

    android:columnCount="4" //設定列數(4列)    android:rowCount="6"      //設定行數(6行)    android:orientation="horizontal"    //設定相片順序(預設豎直)    android:layout_gravity="fill"         //設定對齊    android:layout_columnSpan="4"   //橫向橫跨幾列(4列)    android:layout_rowSpan="4"        //縱向橫跨幾行(4行)    android:layout_row="2"               //設定組件在第幾行(第二行)    android:layout_column="2"          //設定組件在第幾列(第二列)

 

2、簡單使用

  組件預設佔一行一列

<?xml version="1.0" encoding="utf-8"?><GridLayout xmlns:android="http://schemas.android.com/apk/res/android"    xmlns:tools="http://schemas.android.com/tools"    android:layout_width="wrap_content"    android:layout_height="match_parent"    android:columnCount="4"    android:orientation="horizontal"    android:id="@+id/GirdLayout1"    android:rowCount="6"    tools:context="com.example.xianfengzhang.cleartext.GirdActivity">    <TextView        android:layout_columnSpan="4"        android:layout_gravity="fill"        android:layout_marginLeft="5dp"        android:layout_marginRight="5dp"        android:layout_marginTop="5dp"        android:background="#ffcccc"        android:text="0"        android:gravity="right|bottom"        android:textSize="50sp"/>    <Button        android:layout_columnSpan="2"        android:layout_height="wrap_content"        android:layout_gravity="fill_horizontal"        android:text="回退"/>    <Button        android:layout_columnSpan="2"        android:layout_height="wrap_content"        android:layout_gravity="fill_horizontal"        android:text="清空"/>    <Button android:text="+" />    <Button android:text="1" />    <Button android:text="2" />    <Button android:text="3" />    <Button android:text="-" />    <Button android:text="4" />    <Button android:text="5" />    <Button android:text="6" />    <Button android:text="*" />    <Button android:text="7" />    <Button android:text="8" />    <Button android:text="9" />    <Button android:text="/" />    <Button android:text="." />    <Button android:text="0" />    <Button android:text="=" /></GridLayout>

 

Android之GridLayout網格布局

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.