Recyclerview项目上的波纹效果在某些时候不明显

问题描述:

我在活动和Recyclerview项目之一中有一个recyclerview实现,单击导航到不同的屏幕。但是当用户点击Recyclerview项目时,用户在导航到其他活动之前可以看到连锁效果(在API级别> = 21)。 我的问题是有些时候导航很快,用户无法注意到任何连锁反应。如何在几毫秒内延迟导航,以便用户可以看到一些连锁反应。Recyclerview项目上的波纹效果在某些时候不明显

Recyclerview布局如下

<android.support.v7.widget.RecyclerView 
        android:id="@+id/recyclerView" 
        android:layout_width="match_parent" 
        android:layout_height="match_parent" 
        android:background="@color/white" 
        android:focusable="true" 
        android:clickable="true" 
        android:foreground="?android:attr/selectableItemBackground" 
        android:clipToPadding="false"/> 

Recyclerview项目布局如下

<RelativeLayout 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:orientation="horizontal" 
    android:clickable="true" 
    android:focusable="true" 
    android:background="?android:attr/selectableItemBackground" 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto"> 

    <!-- ListRow Left sied Thumbnail image --> 
    <LinearLayout 
     android:id="@+id/thumbnail" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:padding="@dimen/pad_3dp" 
     android:orientation="vertical" 
     android:layout_alignParentLeft="true" 
     android:layout_marginRight="@dimen/pad_5dp"> 

     <com.unvired.shout.util.CircularImageView 
      android:id="@+id/thumbnail_image" 
      android:layout_width="@dimen/pad_50dp" 
      android:layout_height="@dimen/pad_50dp" 
      app:border_color="?attr/colorPrimary" 
      app:border_width="@dimen/pad_2dp" 
      app:shadow="true" /> 

     <LinearLayout 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content"> 

      <ImageView 
       android:layout_width="@dimen/pad_20dp" 
       android:layout_height="@dimen/pad_15dp" 
       android:id="@+id/chat_red_image" 
       android:layout_centerVertical="true" /> 

      <ImageView 
       android:layout_width="@dimen/pad_20dp" 
       android:layout_height="@dimen/pad_20dp" 
       android:layout_marginLeft="@dimen/pad_5dp" 
       android:id="@+id/chat_reply_image" 
       android:layout_centerVertical="true" /> 
     </LinearLayout> 
    </LinearLayout> 

    <TextView 
     android:id="@+id/name" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignTop="@+id/thumbnail" 
     android:layout_toRightOf="@+id/thumbnail" 
     android:text="Rihanna Love the way lie" 
     android:layout_marginTop="@dimen/pad_5dp" 
     android:textColor="#040404" 
     android:typeface="sans" 
     android:textSize="@dimen/txt_15sp" 
     android:textStyle="bold" /> 

    <TextView 
     android:id="@+id/feed_name" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_below="@id/name" 
     android:textColor="#343434" 
     android:textSize="@dimen/txt_12sp" 
     android:layout_marginTop="1dip" 
     android:layout_toRightOf="@+id/thumbnail" 
     android:text="Just gona stand there and ..." /> 

    <TextView 
     android:id="@+id/time" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:gravity="right" 
     android:layout_alignParentRight="true" 
     android:text="5:45" 
     android:textSize="@dimen/txt_12sp" 
     android:textColor="?attr/colorPrimary" 
     android:layout_marginRight="@dimen/pad_5dp" 
     android:layout_marginTop="@dimen/pad_5dp" 
     android:textStyle="bold" /> 


    <ImageView 
     android:layout_width="@dimen/pad_30dp" 
     android:layout_height="@dimen/pad_30dp" 
     android:id="@+id/conversation_indicator" 
     android:src="@drawable/link" 
     android:layout_alignParentBottom="true" 
     android:layout_alignParentRight="true" /> 
</RelativeLayout> 

你可能喜欢推迟几毫秒,开始新的活动/片段这样

Handler handler = new Handler(); 
handler.postDelayed(new Runnable() { 
    @Override 
    public void run() { 
     startActivity(...) // For starting an activity 

     // Or for doing a fragment transaction 
     // fragmentTransaction.commit(); 
    } 
}, 250);