2017-06-19 50 views
0

如何從我的按鈕中刪除這些邊距?Android/Java - Margin on left/right/bottom

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

我希望能有100%的寬度按鈕:/

我的活動的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" /> 

+1

發佈您的代碼? – Keerthivasan

+0

在您的佈局中,您可能指定了默認邊距刪除它們 – sumit

+1

您可以請張貼您的xml也 –

回答

-1

RelativeLayout你應該使用fill_parent ,也許它是因爲它的家長寬度

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" /> 

+0

http://imgur.com/BVKQx6z – marcinqxd