本文實(shí)例講述了Android改變ExpandableListView的indicator圖標(biāo)實(shí)現(xiàn)方法。分享給大家供大家參考,具體如下:
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 實(shí)例id后調(diào)用xml文件
ExpandableListView mExpandList = (ExpandableListView) findViewById(R.id.expandlist);mExpandList.setGroupIndicator(this.getResources().getDrawable(R.drawable.expand_list_indicator));
注意事項(xiàng):因?yàn)閕ndicator背景圖片會(huì)自動(dòng)拉伸,如果不想圖片被拉伸的話,那么就對(duì)indicator_open ,indicator_close圖片做特殊處理,做成.9.png格式就可以了。
更多關(guān)于Android相關(guān)內(nèi)容感興趣的讀者可查看本站專題:《Android調(diào)試技巧與常見問題解決方法匯總》、《Android開發(fā)入門與進(jìn)階教程》、《Android多媒體操作技巧匯總(音頻,視頻,錄音等)》、《Android基本組件用法總結(jié)》、《Android視圖View技巧總結(jié)》、《Android布局layout技巧總結(jié)》及《Android控件用法總結(jié)》
希望本文所述對(duì)大家Android程序設(shè)計(jì)有所幫助。
新聞熱點(diǎn)
疑難解答
圖片精選