Saturday, 14 September 2013

Android LinearLayout dynamic text struggle

Android LinearLayout dynamic text struggle

I want to achieve displaying 3 items next to each other
[ICON-and-text-inside] [Dynamic Text] [Dynamic List with dynamic width]
The following is my source
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<FrameLayout android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
>
<ImageView
android:layout_width="30dp"
android:layout_height="30dp"
android:id="@+id/imageView"
android:src="@drawable/bullet_bg_36px"
android:scaleType="centerInside"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="10."
android:id="@+id/textView"
android:layout_gravity="center"
android:textColor="#ffffff"
android:textStyle="bold"
android:textSize="14dp"/>
</FrameLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="LongText1 - LongText2 - LongText3 - LongText4"
android:paddingLeft="10dp"
android:layout_gravity="center_vertical"
/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_marginLeft="10dp"
android:layout_marginTop="6dp"
android:measureWithLargestChild="false"
android:layout_weight="1">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="??? reps"
android:textColor="#c2df00"
android:background="#000000"
android:paddingEnd="2dp"
android:paddingStart="2dp"
android:singleLine="true"
android:layout_weight="1"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="with ??? lbs"
android:textColor="#c2df00"
android:background="#000000"
android:paddingEnd="2dp"
android:paddingStart="2dp"
android:singleLine="true"
android:layout_weight="1"/>
</LinearLayout>
</LinearLayout>
Which currently behaves like the following screenshot:

I want the middle [dynamic text] to wrap ONLY, while the first
(icon+textinside) and last (list) to display fully and properly.
Also if the middle text is not wide enough, then I want the list to be
displayed right after it.

No comments:

Post a Comment