我正在尝试将Ripple Effect添加到RecyclerView的项目中.我在网上看了一下,但找不到我需要的东西.我认为它必须是自定义效果.我已经尝试了android:background属性到RecyclerView本身并将其设置为"?android:selectableItemBackground"但它没有工作:
<android.support.v7.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:focusable="true"
android:clickable="true"
android:background="?android:selectableItemBackground"
android:id="@+id/recyclerView"
android:layout_below="@+id/tool_bar"/>
Run Code Online (Sandbox Code Playgroud)
这是我试图将效果添加到的RecyclerView:

我有一个RecyclerView扩展以下网格项:
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/children_tile_border"
android:layout_marginTop="@dimen/children_tile_border"
android:clickable="true"
android:focusable="true"
android:background="?selectableItemBackground"
tools:ignore="RtlHardcoded">
<com.example.app.ui.widget.SquareImageView
android:id="@+id/child_picture"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="visible"
android:layout_alignParentBottom="true"/>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="68dp"
android:background="@color/tile_text_background"
android:gravity="center_vertical"
android:layout_alignParentBottom="true">
..............
</LinearLayout>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
但除非我将SquareImageView's可见性设置为不可见,否则不会出现涟漪效应.似乎涟漪效应低于SquareImageView.我怎么能把它画成SquareImageView?
当有人在RecyclerView内部时,有没有人解决了CardView之谜而没有触摸反馈?
我有一个带有一堆CardViews(一个CardList)的RecyclerView.当我点击任何CardView时,我启动另一个Activity.这工作得很好,但是当我点击CardView时,我看不到任何触摸反馈.
及时,我已经使用以下方法配置了我的CardView(XML):
android:clickable="true"
android:background="?android:selectableItemBackground"
Run Code Online (Sandbox Code Playgroud)
谢谢!
android touch android-cardview android-5.0-lollipop android-recyclerview
我正在尝试在以下条件下使用Lollipop上的列表视图控件:
注意:我被迫使用自定义列表选择器颜色,因为如果我使用白色背景,暗材料主题选择器使用主题的colorControlHighlight颜色为纹波,即40ffffff,并且不显示.
我首先尝试了以下内容:
布局xml
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="@android:color/white" >
<TextView
android:id="@+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<ListView
android:id="@+id/list_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:listSelector="@drawable/list_selector" />
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
list_selector xml
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
android:color="#ff0000" >
</ripple>
Run Code Online (Sandbox Code Playgroud)
并列出视图行xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:gravity="center_vertical"
android:orientation="horizontal"
tools:ignore="UseCompoundDrawables" >
<ImageView
android:id="@+id/list_image"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/list_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
我期待看到的是当我选择一个项目时,选择的项目的颜色为#ff0000.然而,这是我最终看到的:

我希望的是有点接近这种行为 - 但限制在选定的列表行中!我究竟做错了什么?
谢谢,扎克