How to Customize a Progress Bar In Android

前端 未结 9 2415
鱼传尺愫
鱼传尺愫 2020-11-22 16:07

I am working on an app in which I want to show a ProgressBar, but I want to replace the default Android ProgressBar.

So how can I customize

9条回答
  •  醉酒成梦
    2020-11-22 16:36

    If you want to do this in code, here is a sample:

    pd = new ProgressDialog(MainActivity.this);
    pd.setProgressStyle(ProgressDialog.STYLE_SPINNER);
    pd.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
    pd.getWindow().setGravity(Gravity.CENTER_HORIZONTAL|Gravity.CENTER_VERTICAL);
    TextView tv = new TextView(this);
    tv.setTextColor(Color.WHITE);
    tv.setTextSize(20);
    tv.setText("Waiting...");
    pd.setCustomTitle(tv);
    pd.setIndeterminate(true);
    pd.show();
    

    Using TextView gives you an option to change color, size, and font of your text. Otherwise you can just call setMessage(), as usual.

提交回复
热议问题