相关疑难解决方法(0)

Lollipop RippleDrawable vs Pre-Lollipop的选择器

我有不同的draw9patch按钮png作为背景.目前按钮的控制方式selector如下:

<selector xmlns:android="http://schemas.android.com/apk/res/android">
  <item android:drawable="@drawable/pressed" android:state_pressed="true"/>
  <item android:drawable="@drawable/disabled" android:state_enabled="false"/>
  <item android:drawable="@drawable/focused" android:state_focused="true"/>
  <item android:drawable="@drawable/default"/>
</selector>
Run Code Online (Sandbox Code Playgroud)

对于Android Lollipop,他们有RippleDrawable触摸效果,如下所示:

<ripple xmlns:android="http://schemas.android.com/apk/res/android" android:color="?android:colorControlHighlight">
    <item>
    ...
    </item>
</ripple>
Run Code Online (Sandbox Code Playgroud)

关于新的触摸波纹效果:

1:我可以将draw9patch设置为背景RippleDrawable吗?

2:我如何容纳以上两种不同的xml我想遵循材料设计?我是否必须为新的文件夹/布局xml分叉RippleDrawable

android material ripple rippledrawable android-5.0-lollipop

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

RecyclerView项目触摸以突出显示

我正在使用a RecyclerView,当我触摸该项目时,我无法看到任何反馈RecyclerView.我该如何实现?

我试图在用户触摸行时向用户显示反馈RecyclerView.像涟漪效应的东西.

我想知道如何在特定的一行中实现它RecyclerView.

这是回收站视图的自定义行布局.

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="50dp"
    android:id="@+id/drawer_row"
    android:background="?android:attr/selectableItemBackground"
    android:clickable="true">

    <TextView
        android:id="@+id/title"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerVertical="true"
        android:layout_marginLeft="30dp"
        android:layout_marginStart="30dp"
        android:layout_toEndOf="@+id/navigation_image"
        android:layout_toRightOf="@+id/navigation_image"
        android:textSize="17sp" />

    <ImageView
        android:id="@+id/navigation_image"
        android:layout_width="24dp"
        android:layout_height="24dp"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true"
        android:layout_centerVertical="true"
        android:layout_marginLeft="30dp"
        android:layout_marginStart="30dp" />

    <TextView
        android:id="@+id/horizontal_line"
        android:layout_width="match_parent"
        android:layout_height="1dp"
        android:layout_alignParentBottom="true"
        android:background="#F1F1F1" />


</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)

这是的布局Activity具有RecyclerView

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/windowBackground">


    <RelativeLayout
        android:id="@+id/nav_header_container"
        android:layout_width="match_parent"
        android:layout_height="150dp"
        android:layout_alignParentTop="true"
        android:background="@drawable/ic_drawer_header">

        <ImageView
            android:id="@+id/circle_imageview"
            android:layout_width="80dp"
            android:layout_height="80dp"
            android:layout_alignParentLeft="true"
            android:layout_alignParentStart="true"
            android:layout_alignParentTop="true"
            android:background="@drawable/profile_pic"
            android:layout_marginTop="10dp"
            android:layout_marginLeft="10dp" />

        <TextView
            android:id="@+id/textView"
            android:layout_width="wrap_content" …
Run Code Online (Sandbox Code Playgroud)

android material-design android-recyclerview

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