相关疑难解决方法(0)

将Ripple效果添加到RecyclerView项目

我正在尝试将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:

在此输入图像描述

android android-animation android-recyclerview

83
推荐指数
5
解决办法
6万
查看次数

如何以编程方式将selectableItemBackground添加到ImageButton?

android.R.attr.selectableItemBackground存在,但是如何以编程方式将其添加到ImageButton?

另外,我将如何在文档中找到答案?这里提到,但我没有看到它是如何实际使用的任何解释.实际上,我似乎很少发现文档有用,但我希望这是我的错,而不是文档的错.

android attr r.java-file

49
推荐指数
3
解决办法
3万
查看次数

对包含ImageView的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

android ripple android-recyclerview

42
推荐指数
3
解决办法
3万
查看次数

RecyclerView + CardView +触摸反馈

当有人在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

23
推荐指数
2
解决办法
1万
查看次数

列表视图设置自定义波纹选择器

我正在尝试在以下条件下使用Lollipop上的列表视图控件:

  1. 主题类型是默认的Theme.Material(黑暗主题).
  2. 列表视图包含在具有白色背景的较大布局中.
  3. 列表视图应该有一个显示白色背景的列表选择器.

注意:我被迫使用自定义列表选择器颜色,因为如果我使用白色背景,暗材料主题选择器使用主题的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.然而,这是我最终看到的:

在此输入图像描述

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

谢谢,扎克

android android-listview android-5.0-lollipop

12
推荐指数
1
解决办法
1万
查看次数