我有一个缩略图,当用户点击该图像时,
它会弹出(窗口或对话框??)以显示大图像.
(窗口或对话框)背景应该是透明的.
有没有教程?
Dhr*_*tel 11
是的,您可以设置全屏对话框以显示如下图像
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();
Run Code Online (Sandbox Code Playgroud)
其中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>
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
12272 次 |
最近记录: |