我有一个 GridView ,其中有两列,如下所示:
<GridView
android:id="@+id/therapy_grid"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="1dp"
android:numColumns="auto_fit"
android:verticalSpacing="2dp"
android:horizontalSpacing="2dp"
android:stretchMode="columnWidth"
android:adjustViewBounds="true"/>
它会拉伸(stretch)以填充所有宽度,但我希望它能够防止拉伸(stretch)。我也读过这个主题:link ,但找不到解决方案。
最佳答案
要停止拉伸(stretch),请在 xml 中更改stretchMode,如下所示:
android:stretchMode="none"
或使用以下模式之一:
columnWidth
:每列均等拉伸(stretch)。
none
:禁用拉伸(stretch)。
spacingWidth
:每列之间的间距被拉伸(stretch)。
spacingWidthUniform
:每列之间的间距均匀拉伸(stretch)..
您可以找到更多详情here
关于java - 防止列在 GridView 中拉伸(stretch),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56205755/