The following is the button of my actionLayout. Basically, my actionBar has MenuItems and one of the items has the following button as actionLayout.
<?xml version="1.0" encoding="utf-8"?>
<Button xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/fruit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="15dp"
android:layout_marginTop="3dp"
android:background="#999999"
android:clickable="true"
android:text="Apple" />
My problem is the height of the button keeps filling the parent. I want to set margins but nothing is working. Does anyone know a simple way to set the margins?
You can wrap the button in FrameLayout:
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<Button android:id="@+id/fruit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="50dp"
android:layout_marginLeft="50dp"
android:layout_marginTop="3dp"
android:background="#999999"
android:clickable="true"
android:text="Apple" />
</FrameLayout>
And it would look like the following:

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