9

RecyclerView öğesinin öğesine Ripple Efekti eklemek çalışıyorum. İnternete baktım, ama ihtiyacım olanı bulamadım. Ben RecyclerView için android:background kendisini özelliği denenmiş ve "?android:selectableItemBackground" olarak ayarlayın ama işe yaramadı .: gelmişRecyclerview öğeye tıklayın dalgalanma etkisi

My Veli düzeni

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:custom="http://schemas.android.com/apk/res-auto" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:orientation="vertical"> 

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

      <TextView 
       android:id="@+id/txtTitle" 
       style="@style/kaho_panel_sub_heading_textview_style" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" /> 

      <TextView 
       android:id="@+id/txtDate" 
       style="@style/kaho_content_small_textview_style" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" /> 

    </LinearLayout> 
</LinearLayout> 
aşağıda gösterilmiştir bu

<LinearLayout 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:padding="10dp"> 

    <android.support.v7.widget.RecyclerView 
     android:id="@+id/dailyTaskList" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:clickable="true" 
     android:focusable="true" 
     android:scrollbars="vertical" /> 
</LinearLayout> 

ve adaptör şablon gibidir

Bana bir çözüm ver

+0

Hangi ebeveyn için denediniz? Android: background = "? Android: attr/selectableItemBackground" '? –

cevap

27

hile yapmak gerekir öğe düzeni en üst ebeveyne android:background="?attr/selectableItemBackground" ekleme. Ancak bazı durumlarda hala animasyon özlüyor, android:clickable="true" ekleyerek bunu yapar.

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:background="?attr/selectableItemBackground" 
    android:orientation="vertical"> 

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

     <TextView 
      android:id="@+id/txtTitle" 
      style="@style/kaho_panel_sub_heading_textview_style" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" /> 

     <TextView 
      android:id="@+id/txtDate" 
      style="@style/kaho_content_small_textview_style" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" /> 

    </LinearLayout> 
</LinearLayout> 
1

Geri dönüşümcünüzde Görünüm Öğe Ana, Ekle

android:background="?android:attr/selectableItemBackground" 

altındaki Beğen:

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:custom="http://schemas.android.com/apk/res-auto" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:background="?android:attr/selectableItemBackground" 
    android:orientation="vertical"> 

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

      <TextView 
       android:id="@+id/txtTitle" 
       style="@style/kaho_panel_sub_heading_textview_style" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" /> 

      <TextView 
       android:id="@+id/txtDate" 
       style="@style/kaho_content_small_textview_style" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" /> 


    </LinearLayout> 

</LinearLayout>