0

我試圖建立如下動態的警報對話框。一切工作正常。爲什麼alertbuilder對話框在拐角處有額外的黑色?

final Builder builder = new AlertDialog.Builder(context); 
    builder.setView(view); 
      builder.setCancelable(true); 
      builder.setOnCancelListener(new SortOnCancelListener(viewable, this)); 
      dialog = builder.create(); 
      dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); 
      WindowManager.LayoutParams lp = new WindowManager.LayoutParams(); 
      lp.copyFrom(dialog.getWindow().getAttributes()); 

      DisplayMetrics displaymetrics = new DisplayMetrics(); 
      ((Activity) context).getWindowManager().getDefaultDisplay().getMetrics(displaymetrics); 

      lp.width = (int) ((int)displaymetrics.widthPixels * 0.6); 
      lp.height = WindowManager.LayoutParams.WRAP_CONTENT; 

      dialog.show(); 
      dialog.getWindow().setAttributes(lp); 

除非我得到額外的黑色對面角落周圍如下圖所示 enter image description here

請讓我知道我做錯了。

感謝, 沙拉斯

回答

1

添加該代碼

dialog.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT)); 
+0

相信我會檢查,並讓你知道。謝謝 – coders

+0

對話框打開時,背面模糊效果不會顯現。對此有何建議? – coders

+0

檢查此:http://stackoverflow.com/questions/9632120/background-blur-while-using-dialog-box – Cliff

相關問題