问题描述
我有一个基于GridView的日历.我有以下XML布局,选择器设置为null,因此android:listSelector="@null"
符合我从本网站获得的建议.现在,我在GridView的右侧获得了几个像素的宽条.为什么?我已尽力尝试了一切.这是我的XML布局:
I have a GridView based calendar. I have the following XML layout with the selector set to null thus android:listSelector="@null"
in accordance with advise I have got from this site. Now I am getting a few pixels wide strip to the right of the GridView. Why? I have tried everything I can but to avail. Here is my XML layout:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<GridView
android:id="@+id/calendar"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:horizontalSpacing="-1px"
android:numColumns="7"
android:stretchMode="columnWidth"
android:gravity="center"
android:verticalSpacing="-1px"
android:listSelector="@null" >
</GridView>
</LinearLayout>
我得到的是这张照片:
推荐答案
此空间是由于网格每一行的计算不正确造成的.例如,您的设备宽度为320像素,并且您有7行,请尝试满足320像素的任何计算.如果每个单元格的宽度为45.71428571428571 px,则只能将其减小.
This space is due to imperfect calculation for each row of your grid.For example your device width is 320 px and you have 7 rows, try any calculation that meets 320 px. If the width of each cell is 45.71428571428571 px, only then it can be reduced.
其他选项
应用 android:gravity ="center" 网格中的属性,以便空间从左到右均等
applyandroid:gravity="center" property in you grid so that spaces will equally divided from left to right
这篇关于Android GridView不完美,如何在右侧删除多余的空白的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!