2016-01-07 56 views
0

我在XML布局中有一个带有layout_height="wrap_content"的TextView,但文本不在文本框的顶部,有一些像素填充。TextView with layout_height =“wrap_content”没有完全包裹

<TextView 
     android:id="@+id/name" 
     android:background="@color/text_orange" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="bla bla bla" 
     android:textColor="@color/primary_text" 
     android:textSize="17sp" /> 

我该如何实现文本框完全包裹在文本周围,文本和边框之间没有任何填充?

回答

1

试着在你的TextView中使用它。

android:includeFontPadding="false" 

默认情况下,fontPadding为true。 希望它有帮助。

+0

不幸的是还有一些填充... – swalkner

+0

尝试在您的布局上设置负边距,并让我知道这是否解决了您的问题。 'android:layout_marginTop =“ - 5dp” android:layout_marginBottom =“ - 5dp”' – Kristo

+0

是的,它确实 - 我现在知道是什么导致了这种情况:例如Å看起来不错,但A不(=需要负边距) – swalkner

1

您可以设置。

android:includeFontPadding="false" 
相关问题