• 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"
    />
    

    这里写图片描述

  • 相关阅读:
    Momentum Contrast for Unsupervised Visual Representation Learning (MoCo)
    Objective-C Json转Model(利用Runtime特性)
    swift
    关于虚拟机安装mac os 教程详解
    centos快速安装lamp
    第一篇——感悟篇(软工实践)
    2019SDN大作业——负载均衡
    个人作业——软件工程实践总结作业
    2019 SDN上机第7次作业
    2019 SDN上机第6次作业
  • 原文地址:https://www.cnblogs.com/muyuge/p/6152219.html
Copyright © 2020-2023  润新知