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>
网友评论