I have a horizontal LinearLayout containing a Checkbox followed by a TextView next to it. This LinearLayout is dynamically inflated multiple times in a fixed vertical LinearLayout contained within a RelativeLayout. |
The problem is the last line of the TextView gets cut in half. This happens when the dynamic text is long and spans more than one row. Below is my xml portion which causing the problem: |
<LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal"> <CheckBox android:id="@+id/cbAllowTransferOnlyWifi" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentLeft="true" /> <TextView android:id="@+id/text" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentLeft="true" android:layout_gravity="fill" android:text="@string/transfer.over.wifi.only" /> </LinearLayout> |
The solution is to appliy a LayoutGravity to the TextView item like below: |
android:layout_gravity="fill" |
And this is the fix. |
Friday, October 5, 2018
Android: Last line of textview getting cut off / getting hide some parts of text view in LinearLayout
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment