Android开发_弹出图片dialog

Android开发_当前界面弹出图片dialog

以往我们查看图片时,通常是在意个新的activity中打开图片,现在很多主流APP中可以直接在当前界面弹出图片,让用户体验很清爽.其实我们可以通过dialog的形式对图片进行展示

  • 代码其实很简单.

    R.style.edit_AlertDialog_style);
    dialog.setContentView(R.layout.activity_start_dialog);
    ImageView imageView = (ImageView) dialog.findViewById(R.id.iv_show);
    imageView.setBackgroundResource(R.drawable.icon_record_play);
    dialog.show();
    
    
    dialog.setCanceledOnTouchOutside(true);//点击可以退出
    
    Window window = dialog.getWindow();
    WindowManager.LayoutParams attributes = window.getAttributes();
    attributes.x = 0;
    attributes.y = 40;
    dialog.onWindowAttributesChanged(attributes);   
    

Mr.Jin版权所有,转载请声明出处

你可能感兴趣的:(让世界看到我)