其中stretchMode在GridView的Andr​​oid上使用 [英] Which stretchMode to use in GridView on android

查看:244
本文介绍了其中stretchMode在GridView的Andr​​oid上使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下是我的xml code:

Following is my xml code:

<?xml version="1.0" encoding="utf-8"?>
<GridView xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/gridviewgallery"
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent"
    android:columnWidth="@dimen/gridview_column_width"
    android:numColumns="auto_fit"
    android:verticalSpacing="0dp"
    android:horizontalSpacing="0dp"
    android:stretchMode="columnWidth"
    android:gravity="center"
    android:background="#444444"
/>

当我使用的Andr​​oid版本:stretchMode =columnWidth中,它会创建列之间的间隙(尽管它填满整个屏幕宽度) 如果我用安卓stretchMode =无,它被左对齐并没有留在屏幕右侧的(虽然现在还列之间没有缝隙)缝隙 问题是,我想这两个:要充满整个屏幕宽度以及列之间没有间隙。 如何实现的呢?

When I use android:stretchMode="columnWidth" , it creates a gap between the columns(though it fills the screen width) And if I use android:stretchMode="none" , it gets left aligned and there is a gap left on right side of screen(though now there is no gap between columns) Problem is I want both : To fill the screen width as well no gap between columns. How to achieve it?

推荐答案

这是非常简单的家伙,只是删除行

It's very simple dude, just remove the line

android:columnWidth="@dimen/gridview_column_width"

您可以指定任意数量的列,我是给定列数= 4

you can specify any number of columns, i am given number of column = 4

android:numColumns = "4"

这是工作的罚款,我

这篇关于其中stretchMode在GridView的Andr​​oid上使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆