Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

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??

like image 565
jjLin Avatar asked Aug 23 '12 10:08

jjLin


Video Answer


1 Answers

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>
like image 66
Dhruvil Patel Avatar answered Nov 09 '22 22:11

Dhruvil Patel