【发布时间】:2015-01-17 09:45:15
【问题描述】:
我有一个列表视图。我想为 listView 项目设置边框,所以我使用 'shape' xml。
shape_panel_drawable.xml 文件
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >
<solid android:color="#ffffff" />
<padding
android:bottom="8dp"
android:left="8dp"
android:right="8dp"
android:top="8dp" />
<stroke
android:width="1dp"
android:color="#dadada" />
<corners android:radius="8dp" />
</shape>
list_view_item.xml 文件
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/shape_panel_drawable" >
</RelativeLayout>
我的问题是
如果我使用 android:background="@drawable/shape_panel_drawable" - 当我触摸/按下列表项时,我没有在该项上看到选定的背景颜色。如果我删除“背景”,我会看到它。
有人有什么想法吗?如果我使用背景可绘制 - 'shape_panel_drawable',我是否错过了任何东西以便能够看到选定的背景颜色?
谢谢!
【问题讨论】:
标签: android android-listview background background-color listviewitem