Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Button with Left and Right Margin

Tags:

android

layout

I have the following layout

<?xml version="1.0" encoding="utf-8"?>

<Button
    android:id="@+id/sign_in"
    style="@style/ButtonText"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:background="@drawable/custom_button_green"
    android:text="@string/signin_via_email"
    android:textSize="15sp"
    android:typeface="sans" />

Now the button i dont really want to fit the whole width rather i want a margin of 10dp from the left and 10dp from the right. I have set the padding and layout_marginLeft and right attributes but they dont work. Any help ?

Kind Regards

like image 697
AndroidDev Avatar asked Sep 13 '12 11:09

AndroidDev


2 Answers

 <Button
 style="@style/ButtonText"
 android:layout_marginLeft="10dp"
 android:layout_marginRight="10dp"
 android:id="@+id/btnOk"
 android:layout_width="fill_parent"
 android:layout_height="wrap_content"
 android:text="OK" />
like image 74
MAC Avatar answered Sep 19 '22 11:09

MAC


I added

android:padding="10dp"

to

input.xml

..and it worked!

(I using SoftKeyboard source code and also have the same problem)

like image 22
Vừng Nhỏ Avatar answered Sep 19 '22 11:09

Vừng Nhỏ