Android-L CardView 视觉触摸反馈

2023-12-30

谁能向我解释一下如何在 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+:

Add android:foreground="?android:attr/selectableItemBackground"给你的CardView元素。

API 9+:

Add android:foreground="?selectableItemBackground"给你的CardView元素。


编辑:源自中心而不是触摸点的波纹是已知错误,并已修复 https://code.google.com/p/android-developer-preview/issues/detail?id=297.

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Android-L CardView 视觉触摸反馈 的相关文章

随机推荐