How to put a frame or space between EditText's?

1

I have 3 EditText 's in a layout that the weights are distributed between them, but when I go deep with a color, it gives the impression that it is one, would it have a method to edit better or put a margin? / p>

<LinearLayout
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1" >

        <EditText
            android:id="@+id/M00"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:background="#0000ff"
            android:ems="10"
            android:gravity="center"
            android:inputType="numberSigned|numberDecimal"
            android:textColor="#ffffff" >

            <requestFocus />
        </EditText>

        <EditText
            android:id="@+id/M01"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:background="#0000ff"
            android:ems="10"
            android:gravity="center"
            android:inputType="numberSigned|numberDecimal"
            android:textColor="#ffffff" />

        <EditText
            android:id="@+id/M02"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:background="#0000ff"
            android:ems="10"
            android:gravity="center"
            android:inputType="numberSigned|numberDecimal"
            android:textColor="#ffffff" />
</LinearLayout>
    
asked by anonymous 06.04.2015 / 14:29

1 answer

1

On the margin, as I've commented, you can use the android:layout_margin parameter in each of your EditText s, for example:

android:layout_margin="3dp"

This includes margin in the four corners, but if you prefer, you can include only the left or right, where necessary, with layout_marginRight or layout_marginLeft . Remember that for this you will also need the parameters layout_marginStart and layout_marginEnd .

For the borders, you need to create a file inside the res / drawable directory that will represent the background of EditText . I gave the name of edittext_bg.xml :

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
    <solid android:color="#0000ff"/>
    <stroke android:width="1dp" android:color="#ffffff"/>
    <corners android:radius="3dp"/>
</shape>

In this example, the text box will have the blue background (% w / o%), white border (% w / o%), and rounded (% w / o%). This is a basic implementation, but you can increment even more as eg change when having focus and etc.

And then, just change the background of #0000ff :

android:background="@drawable/edittext_bg"
    
06.04.2015 / 14:56