0

how i can remove these margins from my buttons?

https://i.stack.imgur.com/UBPhR.png

I want to have 100% width buttons :/

my activity xml:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="0dp"
tools:context="${relativePackage}.${activityClass}" >

<Button
    android:id="@+id/button1"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:layout_alignParentLeft="true"
    android:layout_marginBottom="34dp"
    android:backgroundTint="#1379ff" />

<Button
    android:id="@+id/Button01"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:layout_alignParentLeft="true"
    android:backgroundTint="#313131" />

    android:layout_alignParentLeft="true"
    android:layout_weight="1"
    android:text="Button" />

2 Answers2

0
Use negative margin to the parent layout like below.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="-5dp"
android:layout_marginRight="-5dp"

 >

<Button
    android:id="@+id/button1"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:layout_marginBottom="34dp"
    android:backgroundTint="#1379ff" />

<Button
    android:id="@+id/Button01"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:backgroundTint="#313131" />

Darsy
  • 133
  • 1
  • 6
-1

in your RelativeLayout you should use fill_parent and maybe it is because of it's Parent Width

S.Hossein Asadollahi
  • 1,450
  • 2
  • 17
  • 22