Question

Hope you are doing well

I want to Justify my Text in TextView,

Is there any way to do that?

Thanks in Advance

Was it helpful?

Solution

XML Layout: declare WebView instead of TextView

<WebView
 android:id="@+id/textContent"
 android:layout_width="fill_parent"
 android:layout_height="wrap_content" />

Java code: set text data to WebView

WebView view = (WebView) findViewById(R.id.textContent);
String text;
text = "<html><body><p align=\"justify\">";
text+= "This is the text will be justified when displayed!!!";
text+= "</p></body></html>";
view.loadData(text, "text/html", "utf-8");

This may Solve your problem.

OTHER TIPS

I use this project to justify text. It works fine with my projects. JustifiedTextView

XML code

<com.codesgood.views.JustifiedTextView
    android:padding="3dp"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:text="@string/card_use_hint"/>

Result

Justified text

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top