2016-01-07 57 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" 
相關問題