【发布时间】:2015-07-06 12:38:53
【问题描述】:
我正在尝试向ImageView 添加涟漪效果。我知道,如果您添加以下背景,您可以模拟图像视图触摸时的涟漪效果。
android:background="?android:attr/selectableItemBackground"
我深入挖掘以查看它真正包含的内容(在侧平台 v21 中检查)。它实际上指向了这个名为item_background.xml的文件。这个文件的内容是:
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_window_focused="false" android:drawable="@color/transparent" />
<!-- Even though these two point to the same resource, have two states so the drawable will invalidate itself when coming out of pressed state. -->
<item android:state_focused="true" android:state_enabled="false" android:state_pressed="true" android:drawable="@drawable/list_selector_background_disabled" />
<item android:state_focused="true" android:state_enabled="false" android:drawable="@drawable/list_selector_background_disabled" />
<item android:state_focused="true" android:state_pressed="true" android:drawable="@drawable/list_selector_background_transition" />
<item android:state_focused="false" android:state_pressed="true" android:drawable="@drawable/list_selector_background_transition" />
<item android:state_focused="true" android:drawable="@drawable/list_selector_background_focused" />
<item android:drawable="@color/transparent" />
</selector>
所有这些导致一堆 9 个补丁图像。给这一切增加涟漪效应的部分在哪里?
【问题讨论】: