Android – How to display information with justify alignment?

By -

Problem: How do i display information with Justify alignment?

I saw many developers asking questions on Stackoverflow for this problems. Here are some:

1. Android TextView Justify Text
2. How to justify text on a TextView made easy- Android
3. Justify Text in TextView Android

We can display justified information in WebView, as such there is no any property/attribute for justify alignment in WebView widget but we can use a simple trick. The Trick is to define html tags with justify alignment as belows:

<html><body style="text-align:justify"> YOUR DATA </body></Html>

Android justify text

FYI, the same justify trick will not work for TextView. Mark Murphy (@commonsware) has already posted answer for TextView: “I do not believe Android supports full justification.”

package com.technotalkative.justifytext;

import android.os.Bundle;
import android.view.Menu;
import android.webkit.WebView;

public class MainActivity extends Activity {

	protected void onCreate(Bundle savedInstanceState) {

		String htmlText = " %s ";
		String myData = "Hello World! This tutorial is to show demo of displaying text with justify alignment in WebView.";

		WebView webView = (WebView) findViewById(;
		webView.loadData(String.format(htmlText, myData), "text/html", "utf-8");


<RelativeLayout xmlns:android=""
    tools:context=".MainActivity" >



Download this example from here:

Paresh Mayani

Paresh Mayani is a lead android developer from India. Currently, He is Sr. Software engineer at InfoStretch Solutions Pvt. Ltd. He has been developing android apps since very 1st version i.e. Android 1.5, he says he has seen days and nights of Android history. He is the Head/Organizer of Google Developers Group (GDG), Ahmedabad

Loading Facebook Comments ...
Loading Disqus Comments ...