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!
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.
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.
If you're looking for this kind of padding on the left and right of this cheeky text :
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
Use padding to add margin between border and text in button.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With