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

setTextSize value similar to TextView #56

Closed khalid-hussain closed 9 years ago

khalid-hussain commented 9 years ago

Hi there,

I currently have both a textView and a documentView (from this library) which the user is allowed to choose the font size for. Unfortunately the documentView scales differently from the textView when using the setTextSize(float) function. Is there something I'm missing?

The project I'm working on can be found here.

Thanks for the library and your time.

mathew-kurian commented 9 years ago

Interesting. Can you provide me a screenshot showing the difference.

khalid-hussain commented 9 years ago

Ah, yes. The following code is what I have in my adapter:

holder.tvDuaTranslation.getDocumentLayoutParams().setTextSize(prefOtherFontSize);
holder.tvDuaReference.setTextSize(prefOtherFontSize);

And this is what I get:

I have to multiply the same value for the documentView at least by 2 to get the same size (or at least what looks like the same to me) as the textView. The code for this:

holder.tvDuaTranslation.getDocumentLayoutParams().setTextSize(prefOtherFontSize * 2);
holder.tvDuaReference.setTextSize(prefOtherFontSize);

And the respective screenshot:

Thanks for your time.

mathew-kurian commented 9 years ago

@khalid-hussain So I think the problem here is that I don't take the font in SP format. I take in raw textsize in pixels. I will address issue this soon but the workaround would be to compute the scaled pixel size (SP) and the pass it into setTextSize. The library will be updated in the next build for addressing this issue.

mathew-kurian commented 9 years ago

Try 2.0.5 and let me know

khalid-hussain commented 9 years ago

That did it. Thanks a lot.

Edonfreiner commented 6 years ago

This issue is still not fixed for me.