I need to create the layout like this but not getting perfect.
getting this

need this way

I am creating this using RelativeLayout and need to create in this only. I am able to create with sub layout using Linearlayout but can this possible without using any sub layout
this is my code
<RelativeLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:padding="15dp">
<TextView android:text="Title" android:textColor="#ffffff" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:textSize="18dp" android:padding="5dp"
android:background="@drawable/tab_cyan" android:id="@+id/title_add_txt"/>
<EditText android:hint="Address Title" android:layout_width="match_parent" android:layout_height="wrap_content"
android:id="@+id/address_title" android:layout_toRightOf="@id/title_add_txt"/>
<TextView android:text="Address" android:textColor="#ffffffff" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:textSize="18dp" android:padding="5dp"
android:background="@drawable/tab_cyan" android:layout_below="@id/title_add_txt"
android:id="@+id/address_txt"/>
<EditText android:hint="Address" android:layout_width="match_parent" android:layout_height="wrap_content"
android:id="@+id/address" android:layout_below="@id/address_title" android:layout_toRightOf="@id/address_txt"/>
</RelativeLayout>
I'm not able to test it, but see if this might help:
<RelativeLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:padding="15dp">
<TextView android:text="Title" android:textColor="#ffffff" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:textSize="18dp" android:padding="5dp"
android:background="@drawable/tab_cyan" android:id="@+id/title_add_txt"/>
<EditText android:hint="Address Title" android:layout_width="match_parent" android:layout_height="wrap_content"
android:id="@+id/address_title" android:layout_toRightOf="@id/title_add_txt"/>
<TextView android:text="Address" android:textColor="#ffffffff" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:textSize="18dp" android:padding="5dp"
android:background="@drawable/tab_cyan" android:layout_below="@id/address_title"
android:id="@+id/address_txt"/>
<EditText android:hint="Address" android:layout_width="match_parent" android:layout_height="wrap_content"
android:id="@+id/address" android:layout_alignTop="@id/address_txt" android:layout_alignLeft="@id/address_title"/>
</RelativeLayout>
What I've done is as follows: align address_txt below address_title (instead of below title_add_txt). I've also changed the alignment of address to align to the top of address_txt and to the left of address_title (this might probably be solved in other ways too).
Ad I said: I'm not able to verify it, but you can give it a try at least.
It seems your TextView and EditText aren't the same size. If you could make them the same size, they would probably align fine.
Providing the size of your views, yourbest bet is probably to stick with your sub LinearLayouts.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With