实现透明遮挡层显示图片(效果如下)
过程如下:
Context context = ManualActivity.this; Dialog dia = new Dialog(context, R.style.edit_AlertDialog_style); dia.setContentView(R.layout.activity_start_dialog); ImageView imageView = (ImageView) dia.findViewById(R.id.img_manual_example); imageView.setBackgroundResource(R.drawable.manual_idcard); dia.show(); dia.setCanceledOnTouchOutside(true); // Sets whether this dialog is Window w = dia.getWindow();
WindowManager.LayoutParams lp = w.getAttributes(); lp.x = 0; lp.y = 40; dia.onWindowAttributesChanged(lp);通过Dialog就可以实现这种效果