TuGordoBello
TuGordoBello

Reputation: 4509

Why when I apply padding to a imageview, 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 visualy is this:

enter image description here

I need separate them, but when I aplly a padding-rigth this happen:

enter image description here What can I do to fix?

Upvotes: 3

Views: 79

Answers (2)

A.R.
A.R.

Reputation: 2641

If you want to separate your images you can follow this

1) Use android:layout_marginRight with respect to 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 with respect to First Image.

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

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

3) You can use view in between these 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"
          ....../>

Upvotes: 0

Hamid Shatu
Hamid Shatu

Reputation: 9700

Use...

android:layout_marginRight

instead of

android:paddingRight

Upvotes: 4

Related Questions