Android Image Dialog/Popup

后端 未结 7 772
臣服心动
臣服心动 2020-12-12 14:08

Is it possible to have just an image popup/come-up in an Android application? It\'s similar to an overriding the normal view of an AlertDialog so that it contains just an im

相关标签:
7条回答
  • 2020-12-12 14:38

    No xml:

    public void showImage() {
        Dialog builder = new Dialog(this);
        builder.requestWindowFeature(Window.FEATURE_NO_TITLE);
        builder.getWindow().setBackgroundDrawable(
            new ColorDrawable(android.graphics.Color.TRANSPARENT));
        builder.setOnDismissListener(new DialogInterface.OnDismissListener() {
            @Override
            public void onDismiss(DialogInterface dialogInterface) {
                //nothing;
            }
        });
    
        ImageView imageView = new ImageView(this);
        imageView.setImageURI(imageUri);
        builder.addContentView(imageView, new RelativeLayout.LayoutParams(
                ViewGroup.LayoutParams.MATCH_PARENT, 
                ViewGroup.LayoutParams.MATCH_PARENT));
        builder.show();
    }
    
    0 讨论(0)
提交回复
热议问题