简体   繁体   English

如何在Android中更改进度对话框的大小?

[英]How to change progress dialog box size in android?

I used this method to create progress dialog box. 我使用这种方法来创建进度对话框。

But it not fit with the screen size. 但它不适合屏幕尺寸。 I want to minimize size of this progress dialog box. 我想最小化此进度对话框的大小。

This is the (AsyncTask) code i used: 这是我使用的(AsyncTask)代码:

ProgressDialog myPd_bar;

@Override
        protected void onPreExecute() {
            // TODO Auto-generated method stub

            myPd_bar=new ProgressDialog(AppleModles.this);
              //myPd_bar.setMessage("Loading....");
              myPd_bar.setTitle("Please Wait..");
              myPd_bar.setProgressStyle(myPd_bar.STYLE_HORIZONTAL);
              myPd_bar.setProgress(0);
              myPd_bar.setMax(30);
              myPd_bar.show();
              new Thread(new Runnable() {
                   @Override
                    public void run() {
                          // TODO Auto-generated method stub
                          try
                          {
                                while(myPd_bar.getProgress()<=myPd_bar.getMax())
                                {
                                    Thread.sleep(1000);
                                    handle.sendMessage(handle.obtainMessage());
                                      if(myPd_bar.getProgress()==myPd_bar.getMax())
                                      {
                                            myPd_bar.dismiss();
                                      }

                                }
                          }catch(Exception e){}
                    }
              }).start();


            super.onPreExecute();
        }

Handler handle=new Handler(){
                  @Override
                  public void handleMessage(Message msg) {
                        // TODO Auto-generated method stub
                        super.handleMessage(msg);
                        myPd_bar.incrementProgressBy(5);
                  }
            };

Can anyone help me to minimize this progress dialog box size? 谁能帮助我最小化此进度对话框的大小?

Maybe this helps for fitting with the screen size : 也许这有助于适应屏幕尺寸:

myPd_bar.show();
Window window = myPd_bar.getWindow();
window.setLayout(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT);

这将解决此问题,此后应写成

progressbar.getWindow().setLayout(width,height);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM