Android XML align overlapping text -
so can understand point, here's image:
so, code (a) following:
<?xml version="1.0" encoding="utf-8"?> <relativelayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="wrap_content" android:background="@drawable/list_selector" android:orientation="horizontal" android:padding="5dip" > <!-- listrow left sied thumbnail image --> <linearlayout android:id="@+id/thumbnail" android:layout_width="wrap_content" android:layout_height="wrap_content" android:padding="3dip" android:layout_alignparentleft="true" android:layout_marginright="5dip" android:background="@drawable/image_bg"> <imageview android:id="@+id/product_image" android:layout_width="50dip" android:layout_height="50dip" android:src="@drawable/bag" android:scaletype="fitxy"/> </linearlayout> <textview android:id="@+id/title_product" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_aligntop="@+id/thumbnail" android:layout_torightof="@+id/thumbnail" android:text="title of product" android:textcolor="#040404" android:textsize="15sp" android:textstyle="bold" android:typeface="sans" android:lines="2" android:gravity="left" /> <textview android:id="@+id/model_product" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@id/title_product" android:textcolor="#343434" android:textsize="10dip" android:layout_margintop="1dip" android:layout_torightof="@+id/thumbnail" android:text="model..." /> <textview android:id="@+id/price_product" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignparentright="true" android:layout_aligntop="@id/title_product" android:gravity="right" android:text="10,99€" android:layout_marginright="5dip" android:textsize="13dip" android:textcolor="#10bcc9" android:textstyle="bold"/> </relativelayout>
and code (b):
<?xml version="1.0" encoding="utf-8"?> <relativelayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="wrap_content" android:background="@drawable/list_selector" android:orientation="horizontal" android:padding="5dip" > <!-- listrow left sied thumbnail image --> <linearlayout android:id="@+id/thumbnail" android:layout_width="wrap_content" android:layout_height="wrap_content" android:padding="3dip" android:layout_alignparentleft="true" android:layout_marginright="5dip" android:background="@drawable/image_bg"> <imageview android:id="@+id/product_image" android:layout_width="50dip" android:layout_height="50dip" android:src="@drawable/bag" android:scaletype="fitxy"/> </linearlayout> <textview android:id="@+id/title_product" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_aligntop="@+id/thumbnail" android:layout_torightof="@+id/thumbnail" android:layout_toleftof="@+id/price_product" android:maxlines="1" android:text="title of product" android:textcolor="#040404" android:textsize="15sp" android:textstyle="bold" android:typeface="sans" android:lines="2" android:gravity="left" /> <textview android:id="@+id/model_product" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@id/title_product" android:textcolor="#343434" android:textsize="10dip" android:layout_margintop="1dip" android:layout_torightof="@+id/thumbnail" android:text="model..." /> <textview android:id="@+id/price_product" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignparentright="true" android:text="10,99€" android:layout_marginright="5dip" android:textsize="13dip" android:textcolor="#10bcc9" android:textstyle="bold"/> </relativelayout>
as can see 'title product' overlapping 'price'. best approach achieve want in first image?
try this..
<?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="wrap_content" android:orientation="horizontal" android:background="@drawable/list_selector" android:padding="5dip" > <linearlayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="horizontal" android:padding="5dip" > <!-- listrow left sied thumbnail image --> <linearlayout android:id="@+id/thumbnail" android:layout_width="wrap_content" android:layout_height="wrap_content" android:padding="3dip" android:background="@drawable/image_bg" android:layout_marginright="5dip"> <imageview android:id="@+id/product_image" android:layout_width="50dip" android:layout_height="50dip" android:src="@drawable/bag" android:scaletype="fitxy"/> </linearlayout> <linearlayout android:id="@+id/thumbnail" android:layout_width="0dp" android:layout_height="wrap_content" android:padding="3dip" android:layout_weight="0.7" android:orientation="vertical" android:layout_marginright="5dip"> <textview android:id="@+id/title_product" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="title of product" android:textcolor="#040404" android:textsize="15sp" android:textstyle="bold" android:typeface="sans" android:gravity="left" /> <textview android:id="@+id/model_product" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textcolor="#343434" android:textsize="10dip" android:layout_margintop="1dip" android:text="model..." /> </linearlayout> <linearlayout android:id="@+id/thumbnail" android:layout_width="0dp" android:layout_height="wrap_content" android:padding="3dip" android:layout_weight="0.3" android:orientation="vertical" android:layout_marginright="5dip"> <textview android:id="@+id/price_product" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignparentright="true" android:text="10,99€" android:layout_marginright="5dip" android:textsize="13dip" android:textcolor="#10bcc9" android:textstyle="bold"/> </linearlayout> </linearlayout>
Comments
Post a Comment