textview中文本顶部的额外空间?

Sud*_*hat 3 android relativelayout android-layout

我已经定义了这样的布局 -

`

<ImageView
    android:id="@+id/first_icon"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:src="@drawable/square" />

<ImageView
    android:id="@+id/second_big_image"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_toRightOf="@id/first_icon"
    android:scaleType="fitXY"
    android:src="@drawable/square_big" />

<TextView
    android:id="@+id/line1"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:textColor="#000000"
    android:layout_alignTop="@id/second_big_image"
    android:layout_toRightOf="@+id/second_big_image"
    android:text="AND Here is the text" />
Run Code Online (Sandbox Code Playgroud)

`

在屏幕上,我看到它是这样的.我不明白为什么文本顶部会有一些空间.即使我将它对齐到第二个图像的顶部,它仍然没有对齐.我该怎么做?

在此输入图像描述

我已经尝试过android:alignParentTop="true"android:gravity="top".但似乎没有任何效果.可能这是android textview的行为,但我还是想摆脱那个空间.

设置android:layout_marginTop="-4dip"使它看起来像我想要的.但这是正确的做法吗?

Eri*_*ric 12

那个空间只是字体的间距.它上面有一点点空间,就像任何字体一样(在这种情况下,我猜是这样4dp).

我能想到达到你想要的东西(除了你尝试过的东西)的唯一方法是:

android:includeFontPadding="false"
Run Code Online (Sandbox Code Playgroud)

如果这不起作用,我会按照你现在的方式做到这一点(带有负的上边距).

啊,字体和显示的乐趣!^ _ ^