首页 > 代码库 > Gridview的stretchMode详解附自动宽度
Gridview的stretchMode详解附自动宽度
+ View Code?
1 2 3 4 5 6 7 8 9 | <GridView android:id= "@+id/grid" android:layout_width= "fill_parent" android:layout_height= "fill_parent" android:verticalSpacing= "35px" <!-- grid元素之间的竖直间隔 --> android:horizontalSpacing= "5px" <!--grid元素之间的水平间隔 --> android:numColumns= "auto_fit" <!--表示有多少列,如果设置为auto_fit,将根据columnWidth和Spacing来自动计算 --> android:columnWidth= "100px" <!-- 一般建议采用有像素密度无关的dip或者dp来表示--> android:stretchMode= "columnWidth" <!--如何填满空余的位置,模拟器采用WVGA800* 480 ,每排 4 列,有 4 * 100 + 5 * 3 = 415 ,还余65px的空间,如果是columnWidth,则这剩余的 65 将分摊给 4 列,每列增加 16 /17px。如果采用SpacingWidth,则分摊给 3 个间隔空隙 --> android:gravity= "center" /> |
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。