1

我有以下自定义 GridView:

<android.support.v7.widget.CardView
android:layout_height="wrap_content"
android:layout_width="wrap_content"
app:cardCornerRadius="2dp"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">

  <LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:padding="5dp">

    <ImageView
        android:id="@+id/grid_image"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center_horizontal"
        android:layout_weight="4"/>
    <TextView
        android:id="@+id/grid_text"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center_horizontal"/>
  </LinearLayout>
</android.support.v7.widget.CardView>

现在我有一个带有 CardView 样式的 GridView 但是当我点击任何项目时没有点击效果(我想要 android 5.0 的 cicle 点击效果或至少任何点击效果!)我真的不知道如何归档这个。任何帮助,将不胜感激!

干杯。

4

1 回答 1

1

得到答案,需要添加:setDrawSelectorOnTop(true) gridviews 选择器有效,但它在我的cardview 后面绘制,所以我只需要使用此代码将它绘制在顶部...

这就是帮助我的原因: Android drawSelectorOnTop with GridView

于 2015-01-03T14:02:35.953 回答