2016-03-17 37 views
0

对于我的应用程序,我在特定情况下显示对话框。点击OK后,我看到这个小小的黑盒子出现时间不到一秒钟,但可以清楚地观察到。看起来好像它躺在对话框下。完成对话框活动后出现黑框

我做了一些使用DDMS的调查,但它只是说它的类是android.widget.FrameLayout。它没有任何资源ID。

我怎样才能找出这个元素是什么,我该如何摆脱它?

请参见快照

enter image description here

回答

0

试试这个:

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

OR

您可以尝试在对话框的一些主题,背景透明.. 像这样的东西 - >

<style name="DialogCustomTheme" parent="android:Theme.Holo.Dialog.NoActionBar"> 
<item name="android:windowBackground">@color/transparent</item> 
<item name="android:colorBackgroundCacheHint">@null</item> 

0

组背景布局机器人:背景;

final Dialog dialog = new Dialog(CartActivity.this); 
      dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); 
      dialog.getWindow().getAttributes().height = 
        (int) (Global.getDeviceMetrics(this).heightPixels*0.8); 
      // dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT)); 
      dialog.setContentView(R.layout.dialog_cart); 
      TextView btn_Cancel = (TextView) dialog.findViewById(R.id.btn_cancel); 
      TextView btn_ok1 = (TextView) dialog.findViewById(R.id.btn_ok); 
      dialog.setCancelable(true); 

组对话的宽度和高度根据在屏幕上。

public static DisplayMetrics getDeviceMetrics(Context context) { 
    DisplayMetrics metrics = new DisplayMetrics(); 
    WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); 
    Display display = wm.getDefaultDisplay(); 
    display.getMetrics(metrics); 
    return metrics; 
}