【问题标题】:Android ExpandableListView disable group click effectAndroid ExpandableListView 禁用群组点击效果
【发布时间】:2017-02-08 20:47:21
【问题描述】:

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

希望对组标题点击产生这种影响。

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

有什么方法可以在不更改默认 ExpandableListView 样式的情况下做到这一点?

【问题讨论】:

    标签: android styles expandablelistview


    【解决方案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"/>
    

    【讨论】:

    • 非常有帮助。
    【解决方案2】:

    在 listSelector 中只设置透明颜色....工作正常

    <ExpandableListView
        android:layout_width="match_parent"
        android:listSelector="@android:color/transparent"
        android:layout_height="wrap_content"/>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-04-17
      • 2013-11-13
      • 2012-11-28
      相关资源
      最近更新 更多