I've defined my layout something like this -
`
<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" />
`
And on screen I see it something like this. I don't understand why there is a bit of space on top of the text. Even if I'm aligning it to top of the second image it is still not aligned. How do I do it?

I've already tried android:alignParentTop="true" and also android:gravity="top". But nothing seems to be working. May be this is the behavior of android textview but I still want to get rid of that space.
Setting android:layout_marginTop="-4dip" makes it appear like what I want. But is it the right way of doing it?
That space is just the spacing of the font. It has a slight bit of space above it, as does any font (in this case, I guess that's 4dp).
The only way I can think of to achieve what you want (aside from what you tried) is this:
android:includeFontPadding="false"
If that doesn't work, I'd just do it the way you're doing it now (with the negative top margin).
Ah, the joy of fonts and displays! ^_^
I Think Text view has no problem it is attached to the top (see image image Textview has setted with red BG). The problem is with the Font a you can see the second line also has the gap from the first line so this space is attached with font can try other custom font to check this.

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With