ExpandableListView - 组标志是拉伸以适应文本大小文本、标志、大小、以适应

2023-09-03 23:15:45 作者:忘爱么@

我有组标志的小图标,我用groupIndicator调用选择画,但我看到在默认情况下拉伸的的android图标,配合文字的大小

I have group indication with small icon, and i use groupIndicator to call the selector to draw it but I see android by default stretch that icon to fits the text size

我怎么能prevent的行为,并显示该图标与它的原始大小?

how can i prevent that behavior, and display the icon with it's original size ?

推荐答案

您可以通过 setGroupIndicator 方式添加组指示灯。但默认情况下,指标的Andr​​oid拉伸高度以配合集团项目的高度。 (宽度可以通过 setIndicatorBounds 方式进行调整。) 因此,你应该让组指标的高度完全相同组项目的高度。 (见 ExpandableListView )

You can add group indicator by setGroupIndicator method. But By default, Android stretch height of indicator to fit group item's height. (width can be adjusted by setIndicatorBounds method.) Therefore, you should make group indicator's height exactly same as group item's height. (see ExpandableListView)

否则,您可以完全自定义组指标是 onGroupCollapsed 和 onGroupExpanded 的方法。只要有一些国家的视图,当调用这些方法,改变你的看法的状态。 (见 ExpandableListAdapter )

Otherwise, you can make fully customized group indicator with onGroupCollapsed and onGroupExpanded methods. Just make a view with some states and When these methods are called, change your view's state. (see ExpandableListAdapter)