Remove Padding ImageButton Android

1

I use ImageButton to give a selection effect, but I can not make the image stick to the bottom edge, can someone help me with this?

cantidades buscar.

<ImageButton
    android:id="@+id/imageButton"
    style="?attr/selectableItemBackgroundBorderless"
    android:layout_width="103dp"
    android:layout_height="110dp"
    android:layout_marginLeft="8dp"
    android:layout_row="0"
    android:layout_weight="1"
    android:paddingBottom="-15dp"
    android:paddingTop="30dp"
    android:scaleType="fitCenter"
    app:srcCompat="@drawable/com_facebook_profile_picture_blank_square" />

Greetings.

    
asked by G. Hernandez 22.07.2017 в 02:29
source

2 answers

0

In this case do not define negative padding, define the lower padding with 0dp , so that the image can be positioned correctly in the lower one.

android:paddingBottom="0dp"

and since the height of your ImageButton is 110dp , simply subtract the height of your image at this height to get the upper padding, for example:

<ImageButton
    android:id="@+id/imageButton"
    style="?attr/selectableItemBackgroundBorderless"
    android:layout_width="103dp"
    android:layout_height="110dp"
    android:layout_marginLeft="8dp"
    android:layout_row="0"
    android:layout_weight="1"
    android:paddingBottom="0dp"
    android:paddingTop="50dp"
    android:scaleType="fitCenter"
    app:srcCompat="@mipmap/ic_launcher"
     />
    
answered by 22.07.2017 / 21:59
source
0

You should give more to the paddingTop and the paddingBotton leave it to zero for example:

android: paddingBottom="0dp"

android: paddingTop="90dp"

Greetings

    
answered by 22.07.2017 в 10:53