【问题标题】:ListView item does not show Pressed background color when background draw-able set设置背景可绘制时,ListView 项目不显示按下的背景颜色
【发布时间】: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


    【解决方案1】:

    在您的 ListView 上设置此项可能会有所帮助:

    android:drawSelectorOnTop="true"
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-04-19
      • 1970-01-01
      • 2012-03-10
      • 2016-03-13
      • 2011-09-19
      相关资源
      最近更新 更多