6

我有一个缩略图图像,当用户单击该图像时,
它将弹出(窗口或对话框??)以显示大图像。
(窗口或对话框??)的背景应该是透明的。
有教程吗??

4

2 回答 2

13

是的,您可以设置全屏对话框以显示如下图像

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();

其中 preview_image 是 xml 仅包含 ImageView 和关闭按钮。

这里用于全屏显示图像的 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" />

</RelativeLayout>
于 2012-08-23T10:36:17.653 回答
0

使用背景颜色透明、无标题主题和只有一个 ImageView 的自定义布局的对话框

于 2012-08-23T10:23:42.183 回答