get Centered TextView - Android User Interface

Android examples for User Interface:TextView

Description

get Centered TextView

Demo Code


//package com.java2s;
import android.content.Context;

import android.view.Gravity;
import android.widget.TextView;

public class Main {
    public static TextView getCenteredTextView(Context c, CharSequence text) {
        TextView t = getTextView(c, text);
        t.setGravity(Gravity.CENTER);//from   www  .  j  a v a 2  s . co  m
        return t;
    }

    public static TextView getTextView(Context c, CharSequence text) {
        TextView t = new TextView(c);
        t.setText(text);
        return t;
    }
}

Related Tutorials