How to align-justify a Paragraph if TextView is not align-justify the Text?
By using the WebView we can align a text to justifying text for both RTL and LTR supported Languages.
Just follow the following easy steps.
- Add WebView in your layout abc.xml file
12345678<WebViewandroid:id="@+id/webView"android:layout_width="match_parent"android:layout_height="wrap_content"android:visibility="visible"android:layout_marginBottom="10dp"android:padding="10dp"/>
- Create an HTML tag String
for RTL supported languages.
1234String text;text = "<html><body dir=\"rtl\"; style=\"text-align:justify;\">";text += Your_Content_String;text += "</body></html>";
for LTR supported Languages.
1234String text;text = "<html><body style=\"text-align:justify;\">";text += Your_Content_String ;text += "</body></html>";
- Put String to your WebView
for RTL supported Languages.
1((WebView) v.findViewById(R.id.webView)).loadData(text, "text/html; charset=UTF-8", "utf-8");
for LTR supported Languages.
1((WebView) v.findViewById(R.id.webView)).loadData(text, "text/html", "utf-8");