我有一个带有ImageView和TextView的LinearLayout“卡片”。我希望卡片在用户点击时突出显示。示例请参见http://www.youtube.com/watch?v=Yx1l9Y7GIk8&feature=share&t=15m17s。当用户点击它时,ImageView上的蓝色突出显示
通过设置android:background="@drawable/blue_highlight"
可以轻松完成TextView的工作。下面是RES /绘制/ 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中并为它设置前景属性。 – Bracadabra