0

I've set a 0 dp margin to the button but it has no effect the little margin on top,bottom,lef and right is still there,How can I remove it?

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/activity_map"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="0dp"
    android:paddingLeft="0dp"
    android:paddingRight="0dp"
    android:paddingTop="0dp"
    android:orientation="vertical"
    tools:context="com.myapp.mainpackage.MapActivity">



    <fragment xmlns:android="http://schemas.android.com/apk/res/android"
        android:name="com.google.android.gms.maps.MapFragment"
        android:id="@+id/mapFragment"
        android:layout_width="match_parent"
        android:layout_height="550dp"/>

    <Button
        android:text="Button"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:id="@+id/button4"
        android:layout_margin="0dp"/>

</LinearLayout>

Screenshot

There is a space on the button margins that I can't remove,I want the button fill all the space

AFS
  • 1,433
  • 6
  • 28
  • 52

1 Answers1

0

I had the same problem. The default button comes with margins. Set a button property like this:

android:layout_marginTop="-3dp"

Do the same for the left, right, and bottom margins. Or define a new drawable with these parameters:

<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle"
    android:padding="10dp"
    >
    <solid android:color="@color/colorButtonGray"/>
    <corners
        android:bottomRightRadius="2dp"
        android:bottomLeftRadius="2dp"
        android:topLeftRadius="2dp"
        android:topRightRadius="2dp"/>
</shape> 

The custom shape will not have any built in margins.

Jay
  • 614
  • 5
  • 22