简体   繁体   English

如何在非全屏模式下创建透明对话框

[英]how to create transparent dialog NOT in full screen

I am creating a dialog and setting the content view. 我正在创建一个对话框并设置内容视图。 However my content view is surrounded by black background color. 但是,我的内容视图被黑色背景色包围。 When I try to set the theme to translucent OR set the background drawable to transparent, then the dialog becomes full screen! 当我尝试将主题设置为半透明或将可绘制背景设置为透明时,对话框将变为全屏显示!

Any suggestion how I can set the dialog to be transparent and NOT in full screen? 有什么建议可以将对话框设置为透明而不是全屏显示吗? Thank you very much 非常感谢你

       diag = new Dialog(mActivity);
       //diag.getWindow().setBackgroundDrawable(new ColorDrawable(0)); --> I tried that
       //diag.getWindow().setBackgroundDrawableResource(android.R.color.transparent); -->I tried that too
       diag.requestWindowFeature(Window.FEATURE_NO_TITLE);
       diag.setContentView(R.layout.scoredialog);

I know it's an old question, but others might find useful: 我知道这是一个老问题,但其他人可能会发现有用:

Dialog dialog = new Dialog(mActivity);
dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
dialog.show();

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

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