gpt4 book ai didi

java - 防止列在 GridView 中拉伸(stretch)

转载 作者:行者123 更新时间:2023-12-02 05:30:21 25 4
gpt4 key购买 nike

我有一个 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com