美文网首页
解决dialog 透明背景

解决dialog 透明背景

作者: 颤抖的闪电 | 来源:发表于2019-04-23 19:53 被阅读0次
    AlertDialog.Builder builder = new AlertDialog.Builder(activity,R.style.NoBackGroundDialog);
            final AlertDialog dialog = builder.create();
    
            View dialogView = View.inflate(activity, R.layout.dialog_login, null);
            //设置对话框布局
    //        dialog.setView(dialogView);
    
            ImageView btn_qq_login = dialogView.findViewById(R.id.btn_qq_login);
            ImageView btn_weixin_login = dialogView.findViewById(R.id.btn_weixin_login);
    //        Button btn_guest_login = dialogView.findViewById(R.id.btn_guest_login);
            dialog.show();
            dialog.setContentView(dialogView); //放在show之后,位置也很重要
    

    关键在于 dialog.setView(dialogView)和dialog.setContentView(dialogView)

    <resources>
    
        <style name="NoBackGroundDialog" parent="@android:style/Theme.Holo.Light.Dialog">
            <item name="android:windowBackground">@android:color/transparent</item>
        </style>
    
    </resources>
    

    相关文章

      网友评论

          本文标题:解决dialog 透明背景

          本文链接:https://www.haomeiwen.com/subject/cybbgqtx.html