Alex Rivera | Logout

How can I set the margin of a EditText using xml?

Asked 2011-07-03T06:40:06.180
13

Hi all I have created layout using following code

  <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    >
    <TableLayout android:layout_width="match_parent" android:id="@+id/tableLayout1" android:layout_height="wrap_content">
        <TableRow android:id="@+id/tableRow1" android:layout_width="wrap_content" android:layout_height="wrap_content">
            <TextView android:text="TextView" android:id="@+id/textView1" 
            android:layout_width="wrap_content" android:padding="10dip"


             android:layout_height="wrap_content"></TextView>
            <EditText android:layout_height="wrap_content"
            android:padding="12dip"  android:layout_width="wrap_content" android:text="EditText" android:id="@+id/editText1"></EditText>
        </TableRow>
    </TableLayout>
    <TableRow android:layout_width="match_parent" android:id="@+id/tableRow2" android:layout_height="wrap_content">
        <TextView android:text="TextView" android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/textView2"></TextView>
        <EditText android:text="EditText" android:id="@+id/editText2" android:layout_width="wrap_content" android:layout_height="wrap_content"></EditText>
    </TableRow>
    <TableRow android:layout_width="match_parent" android:id="@+id/tableRow3" android:layout_height="wrap_content">
        <Button android:text="Button" android:id="@+id/button1" android:layout_width="wrap_content" android:layout_height="wrap_content"></Button>
        <Button android:text="Button" android:id="@+id/button2" android:layout_width="wrap_content" android:layout_height="wrap_content"></Button>
    </TableRow>
</Line
Edit
Report

1 Answer

9

Try this for Right_margin

android:layout_marginRight = "15dip"

Try this for left margin

android:layout_marginLeft = "15dip"

if you give value in center

android:gravity = "center_horizontal"
answered 2011-07-03T07:05:43.957

Your Answer