Reputation: 340
So you can understand my point, here's an image:
So, the CODE (A) is the 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 the 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 you can see the 'Title Product' is overlapping the 'Price'. What is the best approach to achieve what I want in the first image?
Upvotes: 0
Views: 405
Reputation: 7439
Either you can put ellipsize at the end of the line or you need to make yout TextView in multiline, I mean you need to allow your textview to find new line when its done with line 1.
android:ellipsize="end"
May be it will work for you.
Upvotes: 1
Reputation: 24853
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>
Upvotes: 1