Over a million developers have joined DZone.

Android – How to Display Information with Justify Alignment?

DZone's Guide to

Android – How to Display Information with Justify Alignment?

Problem: How do I display information with Justify alignment?

· Mobile Zone
Free Resource

Launching an app doesn’t need to be daunting. Whether you’re just getting started or need a refresher on mobile app testing best practices, this guide is your resource! Brought to you in partnership with Perfecto

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 below:

<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.app.Activity;
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(R.id.webView1);
        webView.loadData(String.format(htmlText, myData), "text/html", "utf-8");


<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    tools:context=".MainActivity" >



Download this example from here: Android – JustifyText


Keep up with the latest DevTest Jargon with the latest Mobile DevTest Dictionary. Brought to you in partnership with Perfecto.

java ,mobile ,android ,tips and tricks

Published at DZone with permission of Paresh Mayani. See the original article here.

Opinions expressed by DZone contributors are their own.


Dev Resources & Solutions Straight to Your Inbox

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.


{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}