jjLin
jjLin

Reputation: 3291

How to show a fullsize image after clicking the thumbnail image in Android?

I have a thumbnail image and when user clicks on that image,
it will popup (a window or dialog??) to show the big image.
The background should be transparent for the (window or dialog??).
Is there any tutorial??

Upvotes: 7

Views: 15321

Answers (2)

Dhruvil Patel
Dhruvil Patel

Reputation: 2930

yes you can set full screen dialog to show image like below

final Dialog nagDialog = new Dialog(backgroundsActivity.this,android.R.style.Theme_Translucent_NoTitleBar_Fullscreen);
            nagDialog.requestWindowFeature(Window.FEATURE_NO_TITLE); 
            nagDialog.setCancelable(false);
            nagDialog.setContentView(R.layout.preview_image);
            Button btnClose = (Button)nagDialog.findViewById(R.id.btnIvClose);
            ImageView ivPreview = (ImageView)nagDialog.findViewById(R.id.iv_preview_image);
            ivPreview.setBackgroundDrawable(dd);

            btnClose.setOnClickListener(new OnClickListener() {
                @Override
                public void onClick(View arg0) {

                    nagDialog.dismiss();
                }
            });
            nagDialog.show();

where preview_image is xml contains only ImageView and close button.

Here the xml used for showing the image full screen

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:layout_width="fill_parent"
    android:layout_height="fill_parent">

    <ImageView android:layout_width="fill_parent"
        android:layout_height="fill_parent" android:id="@+id/iv_preview_image" />


    <Button android:layout_width="wrap_content"
        android:layout_height="wrap_content" android:background="@drawable/close"
        android:id="@+id/btnIvClose" android:layout_alignParentRight="true"
        android:layout_alignParentTop="true" />

</RelativeLayout>

Upvotes: 13

PC.
PC.

Reputation: 7024

use a dialog with background color transparent, no-title theme and custom layout having just one ImageView

Upvotes: 0

Related Questions