zoukankan      html  css  js  c++  java
  • 10 GridView 样式属性

    GridView 样式属性:
    1,android:numColumns=”auto_fit” 显示的列数
    如果android:numColumns不设置那么自动每行1列
    如下图
    这里写图片描述
    2,auto_fit:自适应 根据item的宽度和手机屏幕的宽度 来决定一行有多少item
    3,android:verticalSpacing=”10dp” 行和行之间的距离
    代码

    <GridView
    android:id="@+id/gv"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:verticalSpacing="10dp"
    android:numColumns="3"
    />

    这里写图片描述

    4,android:horizontalSpacing=”10dp” 列与列之间距离
    代码:

    <GridView
    android:id="@+id/gv"
    android:layout_width="match_parent"
    android:layout_height="match_parent" 
    android:horizontalSpacing="10dp"
    android:numColumns="3"
    />

    如下图:

    这里写图片描述
    5,android:stretchMode=”spacingWidth”:分配剩余部分
    spacingWidth:将剩余部分分配给列与列之间空格部分
    如果不设置android:columnWidth或者为0那么将全部空间
    都填充为间隔
    这里写图片描述
    我们设置 android:columnWidth=”60dp”
    代码:

    <GridView
    android:id="@+id/gv"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:stretchMode="spacingWidth"
    android:numColumns="3"
    android:columnWidth="60dp"
    />

    这里写图片描述
    columnWidth:将剩余部分分配给 列

    spacingWidthUniform:将剩余部分分配给列与列之间空格部分 还有列与屏幕
    代码:

    <GridView
    android:id="@+id/gv"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:stretchMode="spacingWidthUniform"
    android:numColumns="3"
    android:columnWidth="60dp"
    />
    

    这里写图片描述

  • 相关阅读:
    Centos7 Crontab
    Centos7 php-fpm root 运行,执行 kill 等系统命令
    Centos7 安装系统服务、开机自启动
    CentOS7 安装Python3,开发SocketIO 客户端
    Centos7.6 安装DNS服务器
    exerunexplorer.exe
    Web GIS 离线地图
    DataGridView中添加CheckBox列用于选择行
    Android WebView Demo
    上海华魏光纤传感科技有限公司 招聘 《.NET研发工程师》
  • 原文地址:https://www.cnblogs.com/muyuge/p/6152219.html
Copyright © 2011-2022 走看看