mathew-kurian / TextJustify-Android

:page_facing_up: Android Text Full Jusiftication / Wrapping / Justify / Hyphenate - V2.0
https://github.com/bluejamesbond/TextJustify-Android/wiki
Apache License 2.0
1.86k stars 370 forks source link

Text inside ScrollView not reaching to the end #25

Closed ghost closed 9 years ago

ghost commented 10 years ago

When you put the TextViewEx inside a ScrollVIew the scroller doesnt show complete text, it leaves some behind, its like its not calculating the height properly.

This is the beggining of the textViewEx screenshot 2014-05-03 17 03 00

This is the bottom, and the scroller its maxed out, and as you can see some of the text is missing. screenshot 2014-05-03 17 03 18

ghost commented 10 years ago

solved it adding more padding to the bottom

TextViewEx.java:81 super.setPadding(left+10, top, right+10, bottom+80);

EDIT: Not solved, on bigger texts the problem returns... andy ideas?

jribal commented 10 years ago

+80 use real pixels, you have to use dp to be screen independant.

DisplayMetrics metrics = getContext().getResources().getDisplayMetrics();
super.setPadding((int)((left+(metrics.density * 10))), top, (int)(right+(metrics.density * 10)), (int) (bottom+(metrics.density * 40)));
ralf89 commented 10 years ago

Android match_parent doesn't actually realize that justified text occupies more height then regular text so the content is wrapped according to regular text alignment. Is there a way to tell android that the wrap content has to be made with the justified text method?

I solved it giving an actual layout_height that covers the entire justified text height but I wanted to know if it is the only solution or is it possible to tell the match_parent the actual text height putting some more code in the TextViewEx ?

praveen-kanwar commented 10 years ago

All You Can Do Is while setting text textViewEx.setMinLines(value); And Value Can Be Calculated Through (yourText.length()/30) considering one line contain on average 30 characters.

praveen-kanwar commented 9 years ago

Another Tweak Inside Your XML Put android:lineSpacingMultiplier="1.2" And Inside Your Extended TextView there is a temporary fix comment verticalOffset = horizontalFontOffset = getLineHeight(); at this line Put There verticalOffset = horizontalFontOffset = getLineHeight() - 8;

mathew-kurian commented 9 years ago

Refer to the experimental version posted on README.md

mathew-kurian commented 9 years ago

Refer to updated version. It has been fixed along with major optimizations.