I’ve the following RelativeLayout but i would like to improve it. (make a nice design)
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
android:id="@+navigate/RLayout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#ABABAB"
xmlns:android="http://schemas.android.com/apk/res/android"
>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="10dp"
android:textStyle="bold"
android:id="@+id/hcorpo"
android:layout_centerHorizontal="true"
android:src="@drawable/hcorpo"
android:layout_marginTop="15dp" />.
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="10dp"
android:textStyle="bold|italic"
android:textColor="#000000"
android:id="@+id/hotelinfos"
android:layout_below="@+id/hcorpo"
android:layout_alignLeft="@+id/hcorpo"
android:layout_marginTop="10dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="10dp"
android:textStyle="bold"
android:textColor="#000000"
android:id="@+id/hotelname"
android:layout_below="@+id/hotelinfos"
android:layout_alignLeft="@+id/hotelinfos"
android:layout_marginTop="10dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="10dp"
android:textColor="#000000"
android:id="@+id/hoteladdress"
android:layout_below="@+id/hotelname"
android:layout_alignLeft="@+id/hotelname"
android:layout_marginTop="10dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="10dp"
android:id="@+id/hotelphone"
android:layout_below="@+id/hoteladdress"
android:layout_alignLeft="@+id/hoteladdress"
android:layout_marginTop="10dp"
android:textColor="#12C"
android:textStyle="bold|italic"
android:onClick="onClick"
android:clickable="true" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="10dp"
android:textColor="#12C"
android:onClick="onClick"
android:clickable="true"
android:textStyle="bold|italic"
android:id="@+id/hotelemail"
android:layout_below="@+id/hotelphone"
android:layout_alignLeft="@+id/hotelphone"
android:layout_marginTop="10dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="10dp"
android:textColor="#000000"
android:textStyle="bold|italic"
android:id="@+id/bookinginfos"
android:layout_below="@+id/hotelemail"
android:layout_alignLeft="@+id/hotelemail"
android:layout_marginTop="20dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="10dp"
android:textColor="#000000"
android:id="@+id/pnr"
android:layout_below="@+id/bookinginfos"
android:layout_alignLeft="@+id/bookinginfos"
android:layout_marginTop="10dp"
android:layout_marginRight="10dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="10dp"
android:textColor="#000000"
android:id="@+id/segmentCode"
android:layout_below="@+id/bookinginfos"
android:layout_toRightOf="@+id/pnr"
android:layout_marginTop="10dp"
android:layout_marginRight="20dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="10dp"
android:textColor="#000000"
android:id="@+id/checkin"
android:layout_below="@+id/pnr"
android:layout_alignLeft="@+id/pnr"
android:layout_marginTop="10dp"
android:layout_marginRight="10dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="10dp"
android:textColor="#000000"
android:id="@+id/checkout"
android:layout_below="@+id/pnr"
android:layout_toRightOf="@+id/checkin"
android:layout_marginTop="10dp"
android:layout_marginRight="20dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="10dp"
android:textColor="#000000"
android:id="@+id/nights"
android:layout_below="@+id/pnr"
android:layout_toRightOf="@+id/checkout"
android:layout_marginTop="10dp"
android:layout_marginRight="20dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="10dp"
android:textColor="#000000"
android:id="@+id/roomType"
android:layout_below="@+id/checkin"
android:layout_alignLeft="@+id/checkin"
android:layout_marginTop="10dp"
android:layout_marginRight="10dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="10dp"
android:textColor="#000000"
android:id="@+id/boardBasis"
android:layout_below="@+id/roomType"
android:layout_alignLeft="@+id/roomType"
android:layout_marginRight="10dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="10dp"
android:textColor="#000000"
android:id="@+id/paxNames"
android:layout_below="@+id/boardBasis"
android:layout_alignLeft="@+id/boardBasis"
android:layout_marginTop="10dp"
android:layout_marginRight="10dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="10dp"
android:textColor="#000000"
android:textStyle="bold|italic"
android:id="@+id/forHotel"
android:layout_below="@+id/paxNames"
android:layout_alignLeft="@+id/paxNames"
android:layout_marginTop="20dp"
android:layout_marginRight="10dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="10dp"
android:textColor="#000000"
android:id="@+id/supplierCode"
android:layout_below="@+id/forHotel"
android:layout_alignLeft="@+id/forHotel"
android:layout_marginTop="10dp"
android:layout_marginRight="10dp" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/picture"
android:layout_below="@+id/hcorpo"
android:layout_alignRight="@+id/hcorpo"
android:layout_marginTop="10dp"/>
</RelativeLayout>
I would like to do something like the tripadvisor app: http://hpics.li/d961aa3
explanation:
For example i would like to put the following part in a nice white rectangle:
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="10dp"
android:textStyle="bold|italic"
android:textColor="#000000"
android:id="@+id/hotelinfos"
android:layout_below="@+id/hcorpo"
android:layout_alignLeft="@+id/hcorpo"
android:layout_marginTop="10dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="10dp"
android:textStyle="bold"
android:textColor="#000000"
android:id="@+id/hotelname"
android:layout_below="@+id/hotelinfos"
android:layout_alignLeft="@+id/hotelinfos"
android:layout_marginTop="10dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="10dp"
android:textColor="#000000"
android:id="@+id/hoteladdress"
android:layout_below="@+id/hotelname"
android:layout_alignLeft="@+id/hotelname"
android:layout_marginTop="10dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="10dp"
android:id="@+id/hotelphone"
android:layout_below="@+id/hoteladdress"
android:layout_alignLeft="@+id/hoteladdress"
android:layout_marginTop="10dp"
android:textColor="#12C"
android:textStyle="bold|italic"
android:onClick="onClick"
android:clickable="true" />
Should i create a new RelativeLayout with another background color?
Any help is appreciated !
To get round rectangles as background in any layout, you can use 9 patch PNG images or use shape class to create custom drawables.
Just check my sample code below, it may useful to you.
main.xml in layout folder
bg.xml in drawable folder
Java file
The output is