Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android: text in TextView won't fill all the available space

I have a textview in android but the text won't wrap consistently and properly.

In this first image:

first image

The word "little" clearly has enough space to populate the first line. However, it decides to get pushed off into the second line. If I make the text of the body shorter though,

second image

You can see that it does properly fill that space.

How do I make it that the textview is consistent? Either scenario one or two is fine, but it needs to stay the same regardless of the length of the body.

This is my current code. I have tried messing with gravity and alignment but no success.

<TextView
    android:id="@+id/review_body_shadow"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentEnd="true"
    android:layout_alignParentLeft="true"
    android:layout_alignParentRight="true"
    android:layout_alignParentStart="true"
    android:gravity="fill"
    android:textSize="@dimen/dialog_text_size" />

Thanks! (I apologize for not being able to embed the images; my reputation is not high enough)

Edit: This seems to only be a problem in the emulator. When I load the app onto my phone, I can't duplicate this problem. As such, a solution is no longer necessary.

like image 461
Clifford Bernett Avatar asked Dec 10 '25 23:12

Clifford Bernett


1 Answers

This problem was caused by android:breakStrategy. Setting it to simple fixed this problem.

like image 68
Clifford Bernett Avatar answered Dec 13 '25 14:12

Clifford Bernett



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!