Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
  • How to show the full size image in popup on clicking the image in android

    • 0
    • 0
    • 0
    • 0
    • 1
    • 0
    • 0
    • 0
    • 11.0k
    Comment on it

    Below is the code that will show the full size image in a dialog box popup without defining layout xml file .


    In the code below I have taken two imageview named profile_pic and pro, to get the OnTouchListener action of particular image I have used the code

    int a=v.getId(); intiger "a" will have the value equal to profile_pic if we touched on profile_pic imageview else we will get pro id .


    Since I have copy pasted the images within my app drawable folder  so I am using the path as

    "uri = Uri.parse("android.resource://"+getPackageName()+"/drawable/pro");" If you are using the images on external storage then you have to give the path as   

    "uri = Uri.parse(path of your image);"


    private ImageView profile_pic,pro;
        protected void onCreate(Bundle savedInstanceState) {
           private View.OnTouchListener mTouchListener=new View.OnTouchListener() {
            public boolean onTouch(View v, MotionEvent event) {
                Dialog builder = new Dialog(HomePage.this);
                        new ColorDrawable(;
                builder.setOnDismissListener(new DialogInterface.OnDismissListener() {
                    public void onDismiss(DialogInterface dialogInterface) {
                int a=v.getId();
            uri = Uri.parse("android.resource://"+getPackageName()+"/drawable/pro");    //path of image
                else if( {
          uri = Uri.parse("android.resource://" + getPackageName() + "/drawable/profile"); //path of image
                ImageView imageView = new ImageView(HomePage.this);
                imageView.setImageURI(uri);                //set the image in dialog popup
                //below code fullfil the requirement of xml layout file for dialoge popup
         builder.addContentView(imageView, new RelativeLayout.LayoutParams(
                return false;


 1 Comment(s)

Sign In

Sign up using

Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: