【发布时间】:2021-04-24 06:00:30
【问题描述】:
我是 kotlin 的新手,我正在开发一个使用 gridview 的应用程序。我已经设法使 gridview 工作,但是我想删除每行之间的空间。我尝试将填充和垂直间距设置为 0dp,我的 listSelector 是 @null 但似乎没有任何效果。我应该怎么做才能消除行之间的垂直空间?
网格视图:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/colorPrimary">
<GridView
android:id="@+id/home_grid"
android:numColumns="3"
android:verticalSpacing="0dp"
android:horizontalSpacing="0dp"
android:background="@color/colorPrimary"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="top"
android:stretchMode="columnWidth"
android:listSelector="@null"
android:gravity="center"
android:paddingVertical="0dp"/>
</RelativeLayout>
图像视图:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/colorPrimary">
<ImageView
android:id="@+id/grid_image"
android:layout_width="200dp"
android:layout_height="200dp"
android:adjustViewBounds="true"/>
</RelativeLayout>
【问题讨论】:
标签: android xml kotlin gridview