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 369 forks source link

Spannable TextView with different colors #21

Closed andresgr closed 9 years ago

andresgr commented 10 years ago

Given the following program:

TextViewEx textView = (TextViewEx) findViewById(R.id.textView1); textView.setText("", true); Spannable span = Spannable.Factory.getInstance().newSpannable("Hello "); span.setSpan(new ForegroundColorSpan(Color.RED), 0, span.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); span = Spannable.Factory.getInstance().newSpannable(" world!"); span.setSpan(new ForegroundColorSpan(Color.GREEN), 0, span.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);

The output text is printed without any red or green color. Is there any way to solve the justifying of a TextViewEx with different styles?

jamshid88 commented 10 years ago

i think, TextViewEx lost spannable style, because it is working only with String (not Charsequence or child).

andresgr commented 10 years ago

So, is there a way to apply the justifying algorithm to a CharSequence, avoiding the lost of the spannable styles?

mathew-kurian commented 10 years ago

Can you explain a bit about how Spannables are encoded?

jamshid88 commented 10 years ago

i think, you have to replace String with Charsequence in the source, but you will have some problems. for example: Chasequence hasn't split function, you have to write your split function for Charsequnce, etc...

Nomane commented 10 years ago

Any news about this issue ? I think it is a very useful feature since this library is mainly used for news or chat I think and in these use case text is often formatted ("bold", "italic", color ..)

mathew-kurian commented 10 years ago

Check out the experimental version. It is currently a work in progress, but it should provide you with Spannable support. Refer to README.md

mathew-kurian commented 9 years ago

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

Edonfreiner commented 7 years ago

This is still not working for me how do I change the background of the DocumentView?