Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Margin inside buttons

I'm trying to have some margins inside a button between the text and the borders but I don't know how to specify them.

The only way I know is using android:layout_width="...", but this is not relative to the text size.

Thanks!

like image 453
Javier Manzano Avatar asked Dec 15 '11 09:12

Javier Manzano


People also ask

What is padding on a button?

Padding controls the space inside the button, and not only provides buffering room between the text and the border or edge, but it also increases the amount of clickable real-estate.

How do you set margins in material UI button?

To add padding and margin to all React Material-UI components, we can use the Box component. We use Material UI's Box component to add a container with margin and padding. We set the margin on all sides with the m prop and we set the top padding with the pt prop.


2 Answers

If you're looking for this kind of padding on the left and right of this cheeky text : enter image description here

Here is what you do. :

   <Button
    android:id="@+id/she_was_good"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_centerHorizontal="true"
    android:soundEffectsEnabled="false"
    android:layout_alignParentBottom="true"
    android:paddingRight="25dp"
    android:paddingLeft="25dp"
    android:text="@string/im_sorry_lol_str" />

The part you are looking for is paddingRight and paddingLeft

like image 105
Reno Avatar answered Oct 07 '22 17:10

Reno


Use padding to add margin between border and text in button.

like image 38
Vishal Pawar Avatar answered Oct 07 '22 19:10

Vishal Pawar