Why, when I apply the addition to the representation of the image, the image is compressed?

I have the following code:

<LinearLayout 
        android:id="@+id/aceptar_y_rechazar_tu_mesa"
        android:layout_height="wrap_content"
        android:layout_width="match_parent"
        android:orientation="horizontal"
        android:padding="10dp"
        >
         <ImageView
             android:id="@+id/aceptar_tu_mesa"
             android:layout_width="20dp"
             android:layout_height="20dp"
             android:scaleType="centerInside"
             android:src="@drawable/checked" 
             />
         <ImageView 
             android:id="@+id/rechazar_tu_mesa"
             android:layout_width="20dp"
             android:layout_height="20dp"
             android:scaleType="centerInside"
             android:src="@drawable/menos"
             />

    </LinearLayout>

and visually it is:

enter image description here

I need to separate them, but when I use padding-line :

enter image description here What can I do to fix it?

+3
source share
2 answers

Using...

android:layout_marginRight

instead

android:paddingRight
+4
source

If you want to separate your images, you can follow this.

1) Use android: layout_marginRight relative to the second image.

<ImageView
         android:id="@+id/aceptar_tu_mesa"
         android:layout_marginRight="10dp"
         .....  />
<ImageView
          android:id="@+id/rechazar_tu_mesa"
          ....../>

2) Use android: layout_marginLeft relative to the First Image.

<ImageView
         android:id="@+id/aceptar_tu_mesa"

         .....  />
<ImageView
          android:id="@+id/rechazar_tu_mesa"
          android:layout_marginLeft="10dp"
          ....../>

3) You can use the view between the two images to separate them

<ImageView
         android:id="@+id/aceptar_tu_mesa"
                      .....  />
<View 
    android:layout_width="10dp"
    android:layout_height="10dp"/>

<ImageView
          android:id="@+id/rechazar_tu_mesa"
          ....../>
0
source

All Articles