Adjust image inside button

Asked

Viewed 1,050 times

0

Does anyone know how to adjust the image to the size of the button without it being cropped?

inserir a descrição da imagem aqui

Button:

  <Button
    android:id="@+id/funcionario"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_marginLeft="30dp"
    android:layout_marginRight="30dp"
    android:text="| Ver Funcionários"
    android:background="@drawable/botoes"
    android:drawableLeft="@drawable/funcionario"
    android:drawableTint="#ffff"/>

1 answer

-1

Use the attribute padding should solve your problem.

<Button
    android:id="@+id/funcionario"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_marginLeft="30dp"
    android:layout_marginRight="30dp"
    android:padding="10dp"
    android:text="| Ver Funcionários"
    android:background="@drawable/botoes"
    android:drawableLeft="@drawable/funcionario"
    android:drawableTint="#ffff"/>

This link can help you understand how padding works and how it is different from margin https://stackoverflow.com/questions/4619899/difference-between-a-views-padding-and-margin/4619934

  • 1

    It didn’t work, it’s still big d+, and if I put a height like 50 dp, the image gets cropped

  • Have you tried using a layout, Linearlayout for example, instead of a button?

  • The button is inside a linear

  • So, it doesn’t use Button but some layout that allows you better control of the views inside.

Browser other questions tagged

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