Android的-L CardView视觉触摸反馈 [英] Android-L CardView Visual Touch Feedback
问题描述
可能有人向我解释如何实现一些被证明在谷歌I / O 2014 CardView内的视觉触感反馈。
下面是我如何使用CardView在XML中,有可能是一些小的,我很想念,所以我只是想知道,如果有人可以帮助我吗?。
< - !一个CardView - >
< android.support.v7.widget.CardView
的xmlns:card_view =http://schemas.android.com/apk/res-auto
机器人:ID =@ + ID / CardView_1
机器人:layout_width =match_parent
机器人:layout_height =WRAP_CONTENT
机器人:layout_marginLeft =10dp
机器人:layout_marginRight =10dp
机器人:layout_marginTop =10dp
card_view:cardCornerRadius =4DP
机器人:海拔=2DP>
<的LinearLayout
机器人:ID =@ + ID / LinearLayout_1
机器人:layout_width =match_parent
机器人:layout_height =WRAP_CONTENT
机器人:方向=横向
机器人:的onClick =RunSomeMethod>
<! - 主要CardView内容在这里 - >
< / LinearLayout中> < /android.support.v7.widget.CardView>
API 11 +
添加安卓前景=机器人:ATTR / selectableItemBackground
您 CardView
元素。
API 9 +
添加机器人:前景=?selectableItemBackground
您 CardView
元素
编辑:纹波从中心始发而不是从触摸点是一个的已知的bug,并已得到修复。的
could anybody explain to me how to implement some of the visual touch feedback that was demonstrated at Google I/O 2014 within a CardView.
Here is how I am using the CardView in XML, there is probably something small that I am missing, so I just wondered if anyone could help me?.
<!-- 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"
to your CardView
element.
API 9+:
Add android:foreground="?selectableItemBackground"
to your CardView
element.
Edit: The ripple originating from the center and not from the touch point is a known bug, and has been fixed.
这篇关于Android的-L CardView视觉触摸反馈的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!