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

Viewed 53615

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

but now I want to set the margin. How can I do this using XML?

4 Answers

If you are using android:drawableLeft you have to use

    android:drawablePadding="5dp"
Related