意外的顶部和底部填充在一个TextView? [英] Unexpected top and bottom padding on a TextView?

查看:115
本文介绍了意外的顶部和底部填充在一个TextView?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个TextView。我想设置它的背景色。但颜色填充比它底部的空间更多的顶级空间。

I have a TextView. I want to set its background color. But the color fills more top space than it does bottom space.

<!-- red background. -->
<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textSize="14sp"
    android:textStyle="bold"
    android:background="#f00"
    android:text="10.0" />

这是它呈现的方式(放大展示,绿线由我添加的):

This is how it renders (zoomed in to demonstrate, green lines added by me):

因此​​,额外的空间向上顶使它看起来像文字是不是自己的容器中居中。难道这正常吗?我想文本自身的容器(红色区域)内出现垂直居中。

So the extra space up top makes it look like the text is not centered within its own container. Is this expected? I'd like the text to appear vertically centered within its own container (the red area).

这是在Galaxy Nexus的,现有版本的软糖

This is on a galaxy nexus, stock version of jellybean.

感谢

推荐答案

添加以下属性:

android:includeFontPadding="false"

这篇关于意外的顶部和底部填充在一个TextView?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆