0

I am using fragment, I would like to display the imageView I've got in thumbnail on my Fragment in another view or Dialog ? or something for displaying :)

I would like when we tap on the ImageView, the new view displays, and when we tap on Button, that returns on the main Fragment.

I have implemented my onClickListener, and that works but I don't know how to pass data or whatever for displaying ImageView in full screen...

Here is my code for onClickListener :

    mImageReport.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (zoomOut) {

                zoomOut = false;
            } else {

                zoomOut = true;
            }
        }
    });
xcode_Dev
  • 237
  • 4
  • 16
  • Just a use different full screen layout and set the ImageView as match_parent. And make the view Visible and Invisible on click event. – Kunu Apr 29 '15 at 10:24
  • @Kunu I updated my code, with boolean, now I just need to know how to set different layout and set the ImageView as match_parent. – xcode_Dev Apr 29 '15 at 10:32
  • Is there any good reason for that? If not then I will suggest you to try this. You can transfer images using Intent by converting it to bitmap, but again that will cost a lot of memory and not advisable. – Kunu Apr 29 '15 at 10:34
  • @Kunu Oh yeah, I've to be care about memory... What the best choice for keeping safe memory and do this kind of trick ? – xcode_Dev Apr 29 '15 at 10:35

2 Answers2

0

No need to create new window for displaying full screen image. You can use android default gallery image viewer. Just set full image path or image URI to "mImageReport" as a tag, inside its onClick you can retrieve it. Use following line of code to display full screen image as

startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("content://media/external/images/media/16"))); /** replace with your own uri */
Narendra
  • 609
  • 1
  • 12
  • 28
  • Yeah but my mImageReport loads with URL like http://www.google.com/image.jpg, so how can I pass my data in Uri.parse ? my mImageReport load my url with mCurrentReportString.getUrlImages() – xcode_Dev Apr 29 '15 at 10:40
  • and for displaying it : UrlImageViewHelper.setUrlDrawable(mImageReport, mCurrentReportString.getUrlImages()); – xcode_Dev Apr 29 '15 at 10:41
  • I thought you want to show full screen images from local storage. So you want to load remote images in full screen mode? – Narendra Apr 29 '15 at 10:45
  • Yes, is it possible ? sorry to didn't say that – xcode_Dev Apr 29 '15 at 10:52
  • 1
    Yes its possible but for this you need to create a dialog or fragment for handling this part. Better you create separate fragment for handling this part of showing full screen image. Pass image url to this fragment, you can pass it as arguments, and retrieve in that fragment and load using image loading libraries. – Narendra Apr 29 '15 at 10:54
  • ok thanks for help man ! last question : why backgroundsActivity isn't recognize in fragment ? (have a look on the other reply on this post) – xcode_Dev Apr 29 '15 at 10:55
  • 1
    For image loading http://stackoverflow.com/a/29539506/1878148 and passing image complete path as argument go through this http://stackoverflow.com/a/17436739/1878148 – Narendra Apr 29 '15 at 10:59
0

you can set full screen dialog to show image like below

   final Dialog nagDialog = new Dialog(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();

xml code for layout containing image view and close button only:

     <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" />

manDroid
  • 1,125
  • 3
  • 13
  • 25