【发布时间】:2013-11-07 19:42:28
【问题描述】:
我有一个列表,其中定义了我自己的具有自定义布局的列表视图项。此布局具有带有自定义可绘制对象的背景。
我的 ListView 项目的自定义布局:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/item"
android:clickable="true"
android:focusable="true"
android:focusableInTouchMode="true" >
...
</RelativeLayout>
我的自定义drawable item.xml:
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<!-- background: shadow -->
<item>
<shape
android:dither="true"
android:shape="rectangle" >
<corners android:radius="2dp" />
<solid android:color="@color/itemShadowColor" />
</shape>
</item>
<!-- foreground: surface -->
<item android:bottom="2dp">
<shape
android:dither="true"
android:shape="rectangle" >
<corners android:radius="2dp" />
<solid android:color="@color/itemBackgroundColor" />
</shape>
</item>
</layer-list>
现在这个项目不能再点击了。
你能解释一下为什么,以及我必须做些什么才能获得与单击按钮相同的行为(蓝色背景的选择器)吗?
【问题讨论】:
-
我没有看到任何按下状态的选择器?
-
我必须在drawable中定义它们?如何添加它以及在哪里添加?
-
相信你会按照答案去做的;)
标签: android android-drawable android-selector