开发者

How to preserve aspect ratio of android:groupIndicator in ExpandableListView?

开发者 https://www.devze.com 2023-03-26 13:27 出处:网络
I want to change the groupIndicator icon of an Expan开发者_开发技巧dableListView. I created a stateListDrawable XML and added the drawables I want to show as group indicators.

I want to change the groupIndicator icon of an Expan开发者_开发技巧dableListView. I created a stateListDrawable XML and added the drawables I want to show as group indicators.

So far, so good.

However depending on the height of the row, the icon gets scaled to use the full height of the row and thereby loses its original aspect ratio.

How can I define the group indicator drawable in a way that the aspect ratio of the drawable is always maintained?


(Answered in the comments - converted to a community wiki answer.)

The OP wrote:

I figured out how to do it. One has to define the icon as a 9-patch-drawable. To have the icon itself retain its aspect ratio, add a small transparent area around the icon and mark that as the strechable part of the 9-patch image

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号