我有1英寸高的文字,但視圖框佔用1.5英寸,所以白色字母上方和下方有1/4英寸的黑色空間。我想減少1/4英寸,這樣我就可以在我的6英寸屏幕上獲得5行文本,而不是隻有4行。我可以使用android:lineSpacingMultiplier =「。66」將它們移近一些,但這只是將這些框更靠近一起和1/4英寸的黑色空間覆蓋附近的行的文本。 android:includeFontPadding =「false」什麼都不做。負填充什麼都不做。放在android:lineSpacingExtra =「 - 50sp」中也只是黑邊覆蓋了相鄰的文本行。我想擺脫邊際(實際上,只是大部分)。如何減少Android xml佈局中文本的填充?
我已經嘗試了所有我能想到的選項,包括上面討論的填充和邊距以及填充(包括零和負數)的顯而易見的選項。我無法找到顯示實際文本上方視圖中控制空間的簡單圖。
如何減少浪費的空間?
(我的互聯網斷了最後2小時,我花了一些時間來作出迴應對不起。)
這裏是我的XML:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<TextView
android:id="@+id/textTimer"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:includeFontPadding="false"
android:text="10.01"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textSize="@dimen/font_size" />
<TextView
android:id="@+id/textTimeToLine"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/textTimer"
android:layout_centerHorizontal="true"
android:includeFontPadding="false"
android:text="10.02"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textSize="@dimen/font_size" />
<TextView
android:id="@+id/textTimeToKill"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/textTimeToLine"
android:layout_centerHorizontal="true"
android:includeFontPadding="false"
android:text="10.03"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textSize="@dimen/font_size" />
<TextView
android:id="@+id/textTimeToPin"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/textTimeToKill"
android:layout_centerHorizontal="true"
android:includeFontPadding="false"
android:text="10.03"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textSize="@dimen/font_size" />
<TextView
android:id="@+id/textTimeToCB"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/textTimeToPin"
android:layout_centerHorizontal="true"
android:includeFontPadding="false"
android:text="10.03"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textSize="@dimen/font_size" />
<Button
android:id="@+id/buttonMenu"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:text="Menu"
android:onClick="onMenu"
android:focusable="false"/>
</RelativeLayout>
在這個屏幕截圖,你可以看到,喜歡的邊界或邊緣是我想要減少的區域。
更改字體大小是一個選項。一般而言,您需要上面一行之間的某種空間。以提高可讀性 – Doomsknight 2012-08-09 15:14:31
填充控制文本距離視圖邊緣的距離。你試過把它設置爲0,它不起作用? – 2012-08-09 15:15:13
@Atlos我將填充設置爲0,字體上方仍然有1/4英寸的填充。另外我有android:includeFontPadding =「false」。 – 2012-08-09 15:17:51