现在的位置: 首页 > 综合 > 正文

改变ExpandableListView的indicator图标

2013年09月17日 ⁄ 综合 ⁄ 共 637字 ⁄ 字号 评论关闭

1)定义xml文件先,命名为expand_list_indicator.xml

<?xml version="1.0" encoding="UTF-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
 <item android:state_expanded="true" android:drawable="@drawable/indicator_open" />
 <item android:state_expanded="false" android:drawable="@drawable/indicator_close" />
</selector>

2)在得到ExpandableListView 实例id后调用xml文件

  ExpandableListView mExpandList = (ExpandableListView) findViewById(R.id.expandlist);
  mExpandList.setGroupIndicator(this.getResources().getDrawable(R.drawable.expand_list_indicator));

注意事项:因为indicator背景图片会自动拉伸,如果不想图片被拉伸的话,那么就对indicator_open
,indicator_close图片做特殊处理,做成.9.png格式就可以了。

注意:本文转载自nosxcy博客

抱歉!评论已关闭.