0
I am not being able to align vertically in the center the items of the third line marked in the image. This is a layout of items in a listview.
I’ve tried Gravity="center", layout_gravity="center", layout_centerVertical="true".
I would not like to use a Linearlayout to group the items, some idea ?
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="5dp">
<TextView
style="@style/textBase"
android:id="@+id/labNom"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Nome da categoria"/>
<TextView
style="@style/textNote"
android:id="@+id/labDes"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/labNom"
android:paddingTop="8dp"
android:paddingLeft="8dp"
android:paddingRight="8dp"
android:text="Descrição longa da categoria"/>
<ImageView
android:id="@+id/img1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/labDes"
android:layout_alignParentRight="true"
android:src="@drawable/ic_thumb_up"/>
<TextView
android:id="@+id/lab1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/labDes"
android:layout_toLeftOf="@+id/img1"
android:text="57"/>
</RelativeLayout>
What is the size of the image (mdpi)?
– ramaral
32x32. But the emulator is using 36x36 (Nexus S hdpi). Ooops! could be this.
– Edson Santos
I fixed the resolution of the images, 24x24 - 36x36 - 48x48 and 72x72. No result.
– Edson Santos
The image can be larger than the text if you can’t align it without using padding or margin. Try this: Remove
android:layout_below="@id/labDes"
of the last textView and addandroid:layout_alignBaseline="@+id/img1"
. The image and text should be aligned below, if the centers do not align it is because they have different heights.– ramaral