In my app, I have a form where a user enters his/her name and address details. I have created the layout file as shown in the Image. It looks pretty ok but I want it to look better and moreover when the values in the fields city, state, postcode and country get overlapped with each other if the values are long enough.
I have been trying to make the layout better, but now I need some assistance as I do not have much experience in Android programming/ designing. I have attached images to understand better
Here is the XML file for the layout:
<?xml version="1.0" encoding="utf-8"?>
<ImageView android:id="@id/top_bar_view"
android:layout_width="match_parent" android:layout_height="70dp"
android:background="@drawable/top_bar" android:contentDescription="@string/content" />
<TextView android:id="@+id/txt_recipient"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:layout_alignParentTop="true" android:layout_centerHorizontal="true"
android:layout_marginTop="18dp" android:padding="8dp"
android:text="@string/text_recipient" android:textColor="#FFFFFF"
android:textSize="16sp" />
<RelativeLayout android:id="@+id/Rlayout_recipient"
android:layout_width="match_parent" android:layout_height="match_parent"
android:layout_below="@id/top_bar_view" android:background="@drawable/bg">
<EditText android:id="@+id/edt_rec_name"
android:layout_width="match_parent" android:layout_height="wrap_content"
android:layout_alignParentTop="true" android:layout_centerHorizontal="true"
android:layout_marginLeft="20dp" android:layout_marginRight="20dp"
android:layout_marginTop="22dp" android:background="@drawable/border_email"
android:ems="10" android:hint="@string/name_hint" android:inputType="text"
android:padding="6dp" android:textColor="#FFFFFF"
android:textColorHint="#FFFFFF" />
<EditText android:id="@+id/edt_rec_addr1"
android:layout_width="match_parent" android:layout_height="wrap_content"
android:layout_alignLeft="@+id/edt_rec_name"
android:layout_alignRight="@+id/edt_rec_name" android:layout_below="@+id/edt_rec_name"
android:layout_marginTop="15dp" android:background="@drawable/border_email"
android:ems="10" android:hint="@string/addr1_hint" android:inputType="text"
android:padding="6dp" android:textColor="#FFFFFF"
android:textColorHint="#FFFFFF" />
<EditText android:id="@+id/edt_rec_addr2"
android:layout_width="match_parent" android:layout_height="wrap_content"
android:layout_above="@+id/addr_layout" android:layout_alignLeft="@+id/edt_rec_addr1"
android:layout_alignRight="@+id/edt_rec_addr1"
android:layout_marginBottom="17dp" android:background="@drawable/border_email"
android:ems="10" android:hint="@string/addr2_hint" android:inputType="text"
android:padding="6dp" android:textColor="#FFFFFF"
android:textColorHint="#FFFFFF" />
<RelativeLayout android:id="@+id/addr_layout"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:layout_alignLeft="@+id/edt_rec_addr2"
android:layout_alignParentBottom="true" android:layout_alignRight="@+id/edt_rec_addr2"
android:layout_marginBottom="16dp" android:background="@drawable/border_email">
<EditText android:id="@+id/edt_rec_city"
android:layout_width="120dp" android:layout_height="wrap_content"
android:ems="10" android:hint="@string/city_hint" android:inputType="text"
android:padding="6dp" android:textColor="#FFFFFF"
android:layout_alignParentLeft="true" android:textColorHint="#FFFFFF" />
<EditText android:id="@+id/edt_rec_state"
android:layout_width="125dp" android:layout_height="wrap_content"
android:layout_toRightOf="@+id/edt_rec_city" android:ems="10"
android:hint="@string/state_hint" android:inputType="text"
android:padding="6dp" android:textColor="#FFFFFF"
android:textColorHint="#FFFFFF" />
<EditText android:id="@+id/edt_rec_postcode"
android:layout_width="125dp" android:layout_height="wrap_content"
android:layout_toRightOf="@+id/edt_rec_state" android:ems="10"
android:hint="@string/postcode_hint" android:inputType="number"
android:padding="6dp" android:textColor="#FFFFFF"
android:textColorHint="#FFFFFF" />
<EditText android:id="@+id/edt_rec_ctry"
android:layout_width="125dp" android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true" android:ems="10"
android:focusable="false" android:hint="@string/country_hint"
android:inputType="text" android:padding="6dp" android:textColor="#FFFFFF"
android:textColorHint="#FFFFFF" />
</RelativeLayout>
</RelativeLayout>
<ImageButton android:id="@id/btn_save"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:layout_alignParentRight="true" android:layout_alignParentTop="true"
android:layout_marginRight="14dp" android:contentDescription="@string/content"
android:src="@drawable/icon_save_iphone" />
<ImageButton android:id="@id/btn_cancel"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:layout_alignParentLeft="true" android:layout_alignParentTop="true"
android:layout_marginLeft="16dp" android:contentDescription="@string/content"
android:src="@drawable/icon_cancel_iphone" />
<Button android:id="@+id/btn_contacts" style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:layout_alignBottom="@+id/txt_recipient"
android:layout_marginRight="23dp" android:layout_toLeftOf="@id/btn_save"
android:text="@string/addr_book" />
</RelativeLayout>
I just made some changes which doesn't make the text in each Editext overlap, but I have had to assign fixed width for Editexts in addr_layout. I'm not sure if it's good to do that. Also how can I space the 4 edittexts equally within the relativelayout?