xml - Android design - RelativeLayout (background color) -



xml - Android design - RelativeLayout (background color) -

i've next relativelayout improve it. (make 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 tripadvisor app: http://hpics.li/d961aa3 explanation:

for illustration set next part in 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 create new relativelayout background color?

any help appreciated !

to round rectangles background in layout, can utilize 9 patch png images or utilize shape class create custom drawables.

just check sample code below, may useful you.

main.xml in layout folder

<?xml version="1.0" encoding="utf-8"?> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" > <linearlayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_horizontal" android:layout_margin="20dip" android:orientation="vertical" android:background="@drawable/bg"> <textview android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="testing white rectangle" android:textcolor="#f00" android:padding="10dip" android:textsize="25dip" /> <textview android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="testing white rectangle" android:textcolor="#0f0" android:padding="10dip" android:textsize="25dip" /> </linearlayout> </linearlayout>

bg.xml in drawable folder

<?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"> <solid android:color="#fff"/> <corners android:bottomleftradius="7dip" android:toprightradius="7dip" android:topleftradius="7dip" android:bottomrightradius="7dip" /> </shape>

java file

public class whiterectangle extends activity { /** called when activity first created. */ @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.main); } }

the output is

android xml relativelayout

Comments

Popular posts from this blog

How do I check if an insert was successful with MySQLdb in Python? -

delphi - blogger via idHTTP : error 400 bad request -

postgresql - ERROR: operator is not unique: unknown + unknown -