【问题标题】:GridView element selection has different sizeGridView 元素选择有不同的大小
【发布时间】:2014-04-14 13:09:17
【问题描述】:

我有一个三列和固定高度的 GridView。 一切似乎都很好,但是当我单击一个元素时,选择器比单击的元素大。 如您所见,在图像中,第五个元素被选中,并且选择越过了元素边界。

GridView 布局非常简单

<GridView
    android:id="@+id/gridview"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:gravity="center"
    android:numColumns="3"
    android:stretchMode="columnWidth" />

这个项目也很简单

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="@dimen/row_height"
    android:gravity="center" >

    <ImageView
        android:id="@+id/img"
        android:layout_width="@dimen/width"
        android:layout_height="@dimen/height"
        android:layout_gravity="center"
        android:background="@color/r1" />

</LinearLayout>

我错过了什么?

【问题讨论】:

  • 不要固定你的gridview自定义视图的高度和宽度。
  • 这是默认行为,去掉 onclick 并编写自定义代码以突出显示
  • @Goofy 为什么会这样?更大的选择器是什么意思?

标签: android android-layout gridview android-gridview


【解决方案1】:

也许您在该活动中使用旧的 android 主题 尝试使用全息主题 (@android:style/Theme.Holo.Light.NoActionBar) 并检查是否可以解决您的问题。

【讨论】:

  • 难以置信,但就是这样。我使用的是 Theme.Light.NoActionBar 而不是 Theme.Holo.Light.NoActionBar !
猜你喜欢
  • 2018-07-30
  • 2011-10-02
  • 2013-09-04
  • 2018-11-01
  • 1970-01-01
  • 1970-01-01
  • 2020-05-08
  • 1970-01-01
  • 2020-02-08
相关资源
最近更新 更多