1

我使用这种方法来创建进度对话框。

但它不适合屏幕尺寸。我想最小化这个进度对话框的大小。

这是我使用的(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);
                  }
            };

谁能帮我最小化这个进度对话框的大小?

4

2 回答 2

5

也许这有助于适应屏幕尺寸:

myPd_bar.show();
Window window = myPd_bar.getWindow();
window.setLayout(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT);
于 2013-10-05T07:04:17.220 回答
0

这将解决这个问题,这应该写在show之后

progressbar.getWindow().setLayout(width,height);
于 2017-01-30T11:13:43.407 回答