Misaligned images

Posted on

Question :

I’m using the following .xml as the main screen:

<RelativeLayout xmlns_android="http://schemas.android.com/apk/res/android"
    android_orientation="vertical"
    android_layout_width="match_parent"
    android_layout_height="match_parent">


    <TableLayout
        android_layout_width="match_parent"
        android_layout_height="wrap_content"
        android_stretchColumns="*">

    <TableRow
        android_layout_width="wrap_content"
        android_layout_height="match_parent"
        android_layout_marginTop="15dp">

    <TextView
        android_drawableTop="@mipmap/gasolina"
        android_layout_width="45dp"
        android_layout_height="match_parent"
        android_text="ÁLCOOL X GASOLINA"
        android_onClick="iniciarTela1"
        android_padding="30dp"
        android_gravity="center"
        android_textColor="#7d7d7d" />

    <TextView
        android_drawableTop="@mipmap/moedas"
        android_layout_width="45dp"
        android_layout_height="match_parent"
        android_text="QUANTO VOU GASTAR?"
        android_onClick="iniciarTela2"
        android_padding="20dp"
        android_gravity="center"
        android_textColor="#7d7d7d" />


</TableRow>

    <TableRow
        android_layout_width="wrap_content"
        android_layout_height="match_parent"
        android_layout_marginTop="15dp">

        <TextView
            android_drawableTop="@mipmap/grafico"
            android_layout_width="45dp"
            android_layout_height="match_parent"
            android_text="MÉDIA POR KM PERCORRIDO"
            android_onClick="iniciarTela3"
            android_padding="30dp"
            android_gravity="center"
            android_textColor="#7d7d7d" />

        <TextView
            android_drawableTop="@mipmap/grafico2"
            android_layout_width="45dp"
            android_layout_height="match_parent"
            android_text="MÉDIA POR KM INICIAL/FINAL"
            android_onClick="iniciarTela4"
            android_padding="20dp"
            android_gravity="center"
            android_textColor="#7d7d7d" />


    </TableRow>

</TableLayout>

    <TextView
        android_layout_width="match_parent"
        android_layout_height="wrap_content"
        android_text="AVALIAR APP"
        android_onClick="avaliar"
        android_padding="15dp"
        android_gravity="center"
        android_background="#122d98"
        android_layout_alignParentBottom="true"
        android_textColor="#fff"
        android_textSize="16dp" />


</RelativeLayout>

It looks like this on the screen:

Theproblemisthattheimagesinthesecondcolumnarehigher(theyarenotaligned)untilImadearedlinetogetclearer:

What am I doing wrong? how can I fix this problem?

    

Answer :

The error you are experiencing is in the android:padding property of your TextView .

You are setting 30dp and 20dp . Try to keep this value uniform for both TextView ‘s.

<TextView
    android_drawableTop="@mipmap/grafico2"
    android_layout_width="45dp"
    android_layout_height="match_parent"
    android_text="MÉDIA POR KM INICIAL/FINAL"
    android_onClick="iniciarTela4"
    android_padding="20dp" <!-- altere esse valor para ambos TextView's -->
    android_gravity="center"
    android_textColor="#7d7d7d" />

    

Have you tried using:

Ex:

layout_marginTop=

Or

Layout_marginBotton=

In images

    

Leave a Reply

Your email address will not be published. Required fields are marked *