Android-L CardView 视觉触控反馈

标签 android android-layout android-5.0-lollipop android-cardview

谁能向我解释一下如何在 CardView 中实现在 Google I/O 2014 上展示的一些视觉触摸反馈。

这是我在 XML 中使用 CardView 的方式,我可能缺少一些小东西,所以我只是想知道是否有人可以帮助我?

<!-- A CardView -->
<android.support.v7.widget.CardView
    xmlns:card_view="http://schemas.android.com/apk/res-auto"
    android:id="@+id/CardView_1"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginLeft="10dp"
    android:layout_marginRight="10dp"
    android:layout_marginTop="10dp" 
    card_view:cardCornerRadius="4dp"
    android:elevation="2dp">

    <LinearLayout
        android:id="@+id/LinearLayout_1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:onClick="RunSomeMethod"">

    <!-- Main CardView Content In Here-->

    </LinearLayout> </android.support.v7.widget.CardView>

最佳答案

API 11+:

android:foreground="?android:attr/selectableItemBackground" 添加到您的 CardView 元素中。

API 9+:

android:foreground="?selectableItemBackground" 添加到您的 CardView 元素中。


编辑:源自中心而不是触摸点的波纹是 known bug, and has been fixed .

关于Android-L CardView 视觉触控反馈,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24475150/

相关文章:

安卓 : Remove LocationListener

android - 导航 View 项目的 ActionLayout 显示在右侧

android - 同一个 RadioGroup 中的 RadioButtons,但可以选择两个按钮

android - CardView 在 Pre-Lollipop 的每个边缘都有额外的边距

较低 api 上的 android 5 Activity 转换

java - 从 Uri 获取路径

java - 如何从 arraylist 中的 strings.xml 调用字符串

java - LinearLayout 中的居中对象 (Android)

android - 弹出窗口未在 android L 中正确显示

java - 如何通过改造从 api 获取照片引用