Android ExpandableListView 折叠图标设置到屏幕右侧
要将ExpandableListView的折叠图标设置在屏幕右边,可以在布局文件中使用android:groupIndicator属性,并将其设置为一个Drawable对象,该对象包含一个向右的箭头图标。
例如,可以在布局文件中添加以下代码:
<ExpandableListView
android:id="@+id/myExpandableListView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:groupIndicator="@drawable/ic_arrow_right"/>
在这个例子中,ic_arrow_right是一个Drawable对象,它包含一个向右的箭头图标。
如果需要更改箭头的位置,可以使用setIndicatorBounds()方法来指定左侧和右侧边距的像素值。例如:
myExpandableListView.setIndicatorBounds(0, 0);
这将将箭头放置在右侧,与ExpandableListView的右边缘对齐。您可以根据需要调整左侧和右侧边距的值。
原文地址: https://www.cveoy.top/t/topic/nG2r 著作权归作者所有。请勿转载和采集!