There is layout for ListView. From the left edge in item'e there is a progress bar, and from the right there is a button and a text field are also in LinearLayout. But between them there is a LinearLayout in which there are two text fields, the length of the text in which can be different. Question: how can I fix this LinearLayout so that the text does not climb onto the button to the right of it, but simply transfer the text to a new line.

<?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" xmlns:custom="http://schemas.android.com/apk/res-auto" android:background="@color/colorPrimary" android:orientation="horizontal" android:padding="5dip" > <!-- ListRow Left sied Progress Bar --> <LinearLayout android:id="@+id/progressbar" android:layout_width="wrap_content" android:layout_height="wrap_content" android:padding="3dip" android:layout_alignParentLeft="true" android:layout_marginRight="5dip"> <com.github.lzyzsd.circleprogress.DonutProgress android:id="@+id/donut_progress" android:layout_width="80dp" android:layout_height="80dp" custom:donut_progress="30" /> </LinearLayout> <!-- Title of package--> <LinearLayout android:orientation="vertical" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignBottom="@+id/btnBuy" android:layout_toRightOf="@+id/progressbar" android:layout_toEndOf="@+id/progressbar"> <TextView android:id="@+id/title" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Rihanna Love the way" android:textColor="#040404" android:typeface="sans" android:textSize="20dip" android:textStyle="bold" android:layout_below="@+id/description" android:layout_toRightOf="@+id/progressbar" /> <TextView android:id="@+id/description" android:layout_width="fill_parent" android:layout_height="wrap_content" android:textColor="#343434" android:textSize="15dip" android:text="Just gona stand there and ..." android:layout_centerVertical="true" android:layout_toRightOf="@+id/progressbar" android:layout_toEndOf="@+id/progressbar" /> </LinearLayout> <!-- Buy button --> <Button android:id="@+id/btnBuy" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="BUY 4:45" android:textStyle="bold" android:layout_alignParentTop="true" android:layout_alignParentRight="true" /> <!-- Short description about package --> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="random text" android:id="@+id/count" android:layout_alignParentRight="true" android:layout_below="@+id/btnBuy" /> </RelativeLayout> 

    3 answers 3

    Just replace the parent element with LinearLayout with android:orientation="horizontal" and the last button and text field also in LinearLayout wrap, but with android:orientation="vertical"

      Point to TextView: android:layout_width="match_parent" android:layout_height="match_parent" If it doesn't help, you can also add android:singleLine="false"

      • singleLine defaults to false - P. Ilyin
      • Thank you, did not know - GitHors

      If all these three LinearLayout are inside a horizontally oriented LinearLayout, then the parent LinearLayout set the sumWeight property equal to 10, and the layout_weight of the children as much as you need. layout_width should be set to 0dp for child LinearLayouts. If the root element is not LinearLayout, but for example RelativeLayout, set fixed widths in dp