android – 设置ExpandableListView的自定义指示器不工作

所以我试图设置一个自定义的ExpandableListView指标图标,但它不工作.我创建了一个图标并将其保存到可绘制的文件夹.以下是图标:

这是选择器:

<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:drawable="@drawable/arrow_up" android:state_empty="true"/>
    <item android:drawable="@drawable/arrow_down" android:state_activated="true"/>
</selector>

ExpandableListView xml:

<ExpandableListView
    android:id="@+id/lvExp"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:groupIndicator="@drawable/custom_arrow" />

但是,当我启动应用程序时,根本没有指示灯.任何想法我做错了什么?

解决方法

这应该是诀窍
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:state_expanded="true" android:drawable="@drawable/arrow_up" />
    <item android:drawable="@drawable/arrow_down" />
</selector>

您希望在扩展行时进行state_expanded,然后扩展之外的任何其他状态只是正常的向下箭头.然而,当没有任何扩展到的时候,你应该处理state_empty

相关文章

Android性能优化——之控件的优化 前面讲了图像的优化,接下...
前言 上一篇已经讲了如何实现textView中粗字体效果,里面主要...
最近项目重构,涉及到了数据库和文件下载,发现GreenDao这个...
WebView加载页面的两种方式 一、加载网络页面 加载网络页面,...
给APP全局设置字体主要分为两个方面来介绍 一、给原生界面设...
前言 最近UI大牛出了一版新的效果图,按照IOS的效果做的,页...