create ProgressBar and layout to center - Android User Interface

Android examples for User Interface:ProgressBar

Description

create ProgressBar and layout to center

Demo Code


//package com.java2s;

import android.content.Context;

import android.widget.ProgressBar;
import android.widget.RelativeLayout;

public class Main {
    public static ProgressBar createProgress(Context context) {
        ProgressBar p = new ProgressBar(context);
        p.setIndeterminate(true);//from  ww w  . j  av  a 2s  .com
        RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(
                40, 40);
        lp.addRule(RelativeLayout.CENTER_IN_PARENT);
        p.setLayoutParams(lp);
        return p;
    }
}

Related Tutorials