Android ExpandableListView禁用组点击效果

时间:2017-02-08 20:47:22

标签: android styles expandablelistview

当我点击该项目时,默认的可选样式为橙色背景。

想要对群组标题点击产生此效果。

android:listSelector="@android:color/transparent"这不是一个好主意,因为它也会对子项产生影响。

有没有办法在不更改默认的ExpandableListView样式的情况下执行此操作?

1 个答案:

答案 0 :(得分:1)

不是为选择器设置颜色,而是设置背景形状,例如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"/>