【发布时间】:2017-02-08 20:47:21
【问题描述】:
当我点击项目时,默认的可选样式是橙色背景。
我不希望对组标题点击产生这种影响。
android:listSelector="@android:color/transparent" 这不是一个好主意,因为它也会影响子项目。
有什么方法可以在不更改默认 ExpandableListView 样式的情况下做到这一点?
【问题讨论】:
标签: android styles expandablelistview
当我点击项目时,默认的可选样式是橙色背景。
我不希望对组标题点击产生这种影响。
android:listSelector="@android:color/transparent" 这不是一个好主意,因为它也会影响子项目。
有什么方法可以在不更改默认 ExpandableListView 样式的情况下做到这一点?
【问题讨论】:
标签: android styles expandablelistview
不要为选择器设置颜色,而是设置背景形状,例如 custom_shape.xml:
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="@android:color/transparent" />
... 在你的 xml 中它会是:
<ExpandableListView
android:layout_width="match_parent"
android:listSelector="@drawable/custom_shape"
android:layout_height="wrap_content"/>
【讨论】:
在 listSelector 中只设置透明颜色....工作正常
<ExpandableListView
android:layout_width="match_parent"
android:listSelector="@android:color/transparent"
android:layout_height="wrap_content"/>
【讨论】: