Skip to content Skip to sidebar Skip to footer

Is It Possible To Alter Progress Dialog's Message Or Spinner Position?

I basically want to put message text before progress bar (spinner) in progress dialog in order to look like snackbar.

Solution 1:

There might be some easier way to do this that I'm not thinking of at the moment, but you could override the ProgressDialog's onCreate() method, and fiddle with the layout programmatically. For example:

ProgressDialogpd=newProgressDialog(this) {
    @OverrideprotectedvoidonCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        ProgressBarprogress= (ProgressBar) findViewById(android.R.id.progress);
        LinearLayoutbodyLayout= (LinearLayout) progress.getParent();
        TextViewmessageView= (TextView) bodyLayout.getChildAt(1);

        LinearLayout.LayoutParamsllp=
            (LinearLayout.LayoutParams) messageView.getLayoutParams();
        llp.width = 0;
        llp.weight = 1;

        bodyLayout.removeAllViews();
        bodyLayout.addView(messageView, llp);
        bodyLayout.addView(progress);
    }
};

pd.setMessage("Testing...");
pd.show();

I had a quick look through the source versions, and I think this should work for pretty much all of 'em.

Post a Comment for "Is It Possible To Alter Progress Dialog's Message Or Spinner Position?"