Подтвердить что ты не робот

Как я могу установить поле EditText с помощью xml?

Привет всем, я создал макет, используя следующий код

                    

         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>

но теперь я хочу установить margin.how я могу сделать это с помощью XML?

4b9b3361

Ответ 1

Попробуйте это для левого поля, второго в подобном:

<EditText 
    android:id="@+id/editText1"
    android:layout_height="wrap_content"
    android:layout_width="wrap_content" 
    android:layout_marginLeft="15dp"
    android:padding="12dp"  
    android:text="EditText" > 
</EditText>

Ответ 2

Попробуйте это для Right_margin

android:layout_marginRight = "15dip"

Попробуйте это для левого поля

android:layout_marginLeft = "15dip"

если вы даете значение в центре

android:gravity = "center_horizontal"

Ответ 3

Рекомендации Android теперь предлагают использовать marginStart и marginEnd вместо левого и правого, поэтому:

android:layout_marginStart = "15dp"

Ответ 4

Если вы используете Android: drawableLeft, вы должны использовать

    android:drawablePadding="5dp"