简体   繁体   English

如何使网格视图的宽度在整个屏幕上为100%

[英]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 layoutrelative 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.

相关问题 您能否使警报对话框占据屏幕宽度的100%? - Can you make an alert dialog take 100% of the width on screen? Android使视图高度为屏幕宽度的50% - Android make view height 50% of screen width 如何在Android中使用动态项目宽度制作网格视图(使用回收视图)? - How to make Grid View (using Recycle View) with dynamic item width in android? 使水平回收器视图项目的宽度为屏幕宽度的 70% - Make width of horizontal recycler view items 70% of screen width Android-如何制作包含3张图片的网格(高度33%,宽度100%) - Android - How to have an grid with 3 images (height 33%, width 100%) ANDROID ConstraintLayout - 如何使视图延伸到屏幕其余部分的整个宽度和高度? - ANDROID ConstraintLayout - how to make a view stetch to the entire width and height of remainder of screen? 与可滑动标签视图一起使用时,如何制作自定义操作栏以填充屏幕宽度? - how to make custom actionbar to fill screen width when used with swipable tab view? 如何使表格行适合屏幕宽度? - How to make table row fit screen width? 如何使Android视图在整个应用程序中可见? - How to make an android view visible across the application? 如何使布局成为屏幕宽度的80%? - How to make layout to be 80% of the width of the screen?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM