0

有人知道如何用箭头改变可扩展列表项的小圆圈的颜色吗?我的设计师让我这样做,我不知道该怎么做。

4

2 回答 2

5

您不应该更改箭头颜色,这很复杂并且无论如何都是一个坏主意,因为可绘制的箭头可能因设备而异,因此结果将是不可预测的。

相反,使用该android:groupIndicator属性将默认箭头更改为自定义可绘制对象:

<ExpandableListView ...
    android:groupIndicator="@drawable/group_indicator" >

group_indicator.xml可以是一个选择器,以在项目展开时显示不同的箭头:

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

本教程将为您提供更多详细信息。

于 2012-06-22T14:02:07.883 回答
0

你也可以做一个自己的组件(视图)并覆盖它

public void onDraw(Canvas canvas)

方法。现在你可以画任何你想要的。当然这是很多工作,但这会给你最大的可能性。

于 2012-06-22T14:26:11.703 回答