【发布时间】:2013-11-01 11:29:40
【问题描述】:
我有一个带有 ImageView 和 TextView 的 LinearLayout“卡片”。我希望在用户点击卡片时突出显示卡片。示例见http://www.youtube.com/watch?v=Yx1l9Y7GIk8&feature=share&t=15m17s。
通过设置android:background="@drawable/blue_highlight" 可以轻松地为TextView 完成此操作。下面是 res/drawable/blue_highlight.xml:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_selected="true" android:drawable="@color/selected"/>
<item android:state_pressed="true" android:drawable="@color/pressed"/>
<item android:drawable="@color/bg_window"/>
</selector>
但这不适用于 ImageView,因为图像在前面而背景不可见。如何为 ImageView 提供半透明颜色的触摸高亮效果?
【问题讨论】:
-
我相信你可以把你的LinearLayout放到FrameLayout中并为其设置foreground属性。
标签: android android-imageview touch-feedback