Misaligned images

Asked

Viewed 62 times

3

I’m using the following .xml as a 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:

inserir a descrição da imagem aqui

The problem is the following images of the second column are higher up (they are not aligned) until I made a red line to be sharper:

inserir a descrição da imagem aqui

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

  • First thing you should do is check if there really is no empty space in your png image.

  • the size of the images are equal

2 answers

3


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

You are defining 30dp and 20dp. Try to keep uniform this value 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" />
  • Our silly mistake, I didn’t realize that the padding was different thank you.

  • 1

    @Normal! However, you have spent a lot more time creating a question here in the OS than looking for the real mistake! Not that this is a bad thing, but sometimes we turn to resources before we even think a little bit, and we end up settling down to these situations. Many times I started asking a question, and when I finished it, I already had the solution and I gave up publishing. Hugs. Good luck.

-1

Ever tried to use:

Ex:

layout_marginTop=

Or

Layout_marginBotton=

In the images

Browser other questions tagged

You are not signed in. Login or sign up in order to post.