使用复合drawables在TextView中设置实际的文本填充 [英] Set actual text padding in TextView with compound drawables
问题描述
我有一个ListView
填充了ArrayAdapter
.对于项目,我仅使用单个TextView
布局.我希望某些行设置复合可绘制对象.
I have a ListView
populated with an ArrayAdapter
. For items I use just a single TextView
layout. I want some of the rows to have compound drawables set.
问题:是否可以为TextView
中包含的实际文本设置填充,以使复合可绘制对象也不会获得填充?其他解决方案是锁定文本的宽度.我需要在布局中添加ImageViews
吗?
Question: is there a way to set padding for the actual text that is contained in TextView
so that the compound drawables don't get the padding too? Other solution would be to lock the width of text. Do I need to add ImageViews
to my layout?
谢谢.
推荐答案
我将其发布为答案,以便遇到该帖子的人找到答案.
没有直接的方法来只为文本设置填充,但是您可以为整个TextView
设置正填充,并为drawable设置负填充
There's no direct way to set a padding only to text, but you can set a positive padding to the whole TextView
and set a negative padding for the drawable.
这篇关于使用复合drawables在TextView中设置实际的文本填充的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!