2014-12-27 126 views
1

我有以下的自定義的GridView:CardView裏面的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,但是當我點擊任何一個項目有沒有點擊效果(我想有cicle點擊效果的android 5.0或至少任何點擊效果!),我真的不知道如何archieve這一點。任何幫助,將不勝感激!

乾杯。

回答

1

得到了答案,需要補充一點:setDrawSelectorOnTop(true) 的GridView的選擇工作,但它的繪圖我cardview所以我只需要繪製與此代碼頂級的背後...

這是幫助我出: Android drawSelectorOnTop with GridView