如何删除在Android的TextView的顶部和底部的空间空间、Android、TextView

2023-09-12 22:10:35 作者:面具背后の殇

当我有以下 XML 来的布局的文件,我可以看到下面的图片。如果你看到它,你可能会意识到的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.

推荐答案

尝试安卓includeFontPadding =假来看看是否有帮助。根据我的经验,这将有助于一点点,但没有办法降低的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.