如何在Android的textview上删除顶部和底部空间 [英] How to remove the top and bottom space on textview of Android
问题描述
当我将下面的 XML
包含到 layout 文件中时,我可以看到下面的图像.如果你看到它,你就会意识到 TextView
有顶部和底部的空间.
When I include the below XML
to layout file, I can see the below image. If you see it, you could realize that the TextView
has top and bottom space.
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="E1"
android:background="#ff00ff00"/>
我想删除空格.如何删除它?这叫什么?如果有人有线索..请告诉我.提前致谢.
I wish to remove the space. How to remove it? What is it called? If anyone has clue.. please let me know. Thanks in advance.
推荐答案
尝试 android:includeFontPadding="false"
看看是否有帮助.根据我的经验,这会有所帮助,但无法将 TextView 尺寸减小到精确的像素完美文本大小.
Try android:includeFontPadding="false"
to see if it helps. In my experience that will help a little bit, but there's no way of reducing the TextView dimensions to the exact pixel-perfect text size.
可能会也可能不会产生更好结果的唯一替代方法是作弊并硬连线尺寸以匹配文本大小,例如"24sp"
而不是 "wrap_content"
作为高度.
The only alternative, which may or may not give better results, is to cheat a bit and hard-wire the dimensions to match the text size, e.g. "24sp"
instead of "wrap_content"
for the height.
这篇关于如何在Android的textview上删除顶部和底部空间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!