zoukankan      html  css  js  c++  java
  • Android GridView(九宫图)

     GridView跟ListView都是比较常用的多控件布局,而GridView更是实现九宫图的首选!

    <?xml version="1.0" encoding="utf-8"?>  
    <GridView xmlns:android="http://schemas.android.com/apk/res/android"   
        android:id="@+id/gridview"  
        android:layout_width="fill_parent"   
        android:layout_height="fill_parent"  
        android:numColumns="auto_fit"  
        android:verticalSpacing="10dp"  
        android:horizontalSpacing="10dp"  
        android:columnWidth="90dp"  
        android:stretchMode="columnWidth"  
        android:gravity="center"  
    />  
    <GridView
            android:id="@+id/xxx"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:background="#EEEEEE"
            android:gravity="center"
            android:horizontalSpacing="15dp"
            android:numColumns="2"
            android:padding="15dp"
            android:stretchMode="columnWidth"
            android:verticalSpacing="10dp" >
        </GridView>

    介绍一下里面的某些属性:

    android:numColumns="auto_fit" ,GridView的列数设置为自动

    android:columnWidth="90dp",每列的宽度,也就是Item的宽度
    android:stretchMode="columnWidth",缩放与列宽大小同步
    android:verticalSpacing="10dp",两行之间的边距,如:行一(NO.0~NO.2)与行二(NO.3~NO.5)间距为10dp
    android:horizontalSpacing="10dp",两列之间的边距。

    stareblankly.cn
  • 相关阅读:
    Vue知识总结
    Excel使用技巧
    java框架总结
    java反射学习总结
    java虚拟机
    vue学习知识
    mysql索引知识
    前端函数定义及表格总结
    SpringMVC异常处理
    restful风格的概念
  • 原文地址:https://www.cnblogs.com/stareblankly/p/4920703.html
Copyright © 2011-2022 走看看