[英]How to make the width of a grid view 100% across the screen
I have a grid view inside my layout and I am trying to make it stretch all the way across the screen. 我在布局中有一个网格视图,并且试图使其一直延伸到整个屏幕。 My XML for this gridview follows below. 下面是此网格视图的XML。
<GridView
android:numColumns="auto_fit"
android:gravity="center"
android:stretchMode="columnWidth"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/gridView"
android:layout_below="@+id/editText"
android:columnWidth="400dp"
android:clickable="true"
android:background="#fffefff9"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true" />
The grid view does not completely fill the screens width. 网格视图不能完全填满屏幕宽度。 There are these small margins on the side. 侧面有这些小的边距。 How do I get rid of these margins on the sides of the grid view completely? 如何完全消除网格视图侧面的这些空白? In other word, I want the width of the grid view to be full width. 换句话说,我希望网格视图的宽度为全宽。 On the other hand, fill_parent does make the grid view's width cover 95% of the width of the screen, but there are small margins on the side of the screen. 另一方面,fill_parent确实使网格视图的宽度覆盖了屏幕宽度的95%,但是在屏幕的侧面有很小的空白。 Unfortunately, I am not allowed to post an image since I don't have enough reputation. 不幸的是,由于我没有足够的声誉,因此我无法发布图像。
Add this to your list view's parent it might be a linear layout
or relative layout
将此添加到列表视图的父级中,它可能是linear layout
或relative layout
android:paddingBottom="0dp"
android:paddingLeft="0dp"
android:paddingRight="0dp"
android:paddingTop="0dp"
If there was already padding values change them to that. 如果已经有填充值,请将其更改为该值。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.