Android ProgressDialog设置透明程度

 

public ProgressDialog gotoDialog(Context cxt) {
  MyProgressDialog dialog = new MyProgressDialog(cxt, totalPage);
  dialog.setTitle("跳转");
  dialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
  dialog.setMax(totalPage);

  /**设置透明度*/
  Window window = dialog.getWindow();
  WindowManager.LayoutParams lp = window.getAttributes();
  lp.alpha = 0.7f;// 透明度
  lp.dimAmount = 0.8f;// 黑暗度
  window.setAttributes(lp);
  int start = flipper.getDisplayedChild() + 1;
  if (totalPage > 0) {
   final int total = totalPage;
   dialog.setIndeterminate(false);
   dialog.incrementProgressBy(start * totalPage / total);
   dialog
     .setX(this.getWindowManager().getDefaultDisplay()
       .getWidth() - 40);
   dialog.setCallBack(new MyProgresDialogCallBack() {
    @Override
    public void callback(int scale) {
     if (scale <= 0) {
      scale = 1;
     } else if (scale >= total) {
      scale = total;
     }
     flipper.setDisplayedChild(scale - 1);
     flipper.postInvalidate();
     pageNo.setText("[" + scale + "/" + totalPage + "]");
    }
   });
  }
  return dialog;
 }

你可能感兴趣的:(Android)