简体   繁体   English

OnClickListener在其他Intent / Fragment中以全屏显示ImageView

[英]OnClickListener display ImageView in Full screen in other Intent/Fragment

I am using fragment , I would like to display the imageView I've got in thumbnail on my Fragment in another view or Dialog ? 我使用的片段 ,我想展示我在缩略图上了我的另一个观点或对话片段ImageView的 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. 我想当我们点击ImageView时,将显示新视图,而当我们点击Button时,它将返回到主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... 我已经实现了onClickListener,并且可以使用,但是我不知道如何传递数据或以全屏显示ImageView的方法。

Here is my code for onClickListener : 这是我的onClickListener代码:

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

                zoomOut = false;
            } else {

                zoomOut = true;
            }
        }
    });

No need to create new window for displaying full screen image. 无需创建用于显示全屏图像的新窗口。 You can use android default gallery image viewer. 您可以使用android默认图库图片查看器。 Just set full image path or image URI to "mImageReport" as a tag, inside its onClick you can retrieve it. 只需将完整图像路径或图像URI设置为“ mImageReport”作为标签,就可以在其onClick内进行检索。 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 */

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: 仅包含图像视图和关闭按钮的布局XML代码:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM