简体   繁体   English

Android Studio Alertdialog显示图片完整大小

[英]Android Studio Alertdialog show image full size

I want to the show Full size of the image in the alert dialog, When I click on the imagebutton in the android project. 我想在警告对话框中显示图像的全尺寸,当我点击android项目中的图像按钮时。 How can I do? 我能怎么做?

In xml file - 在xml文件中 -

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">

      <ImageView
          android:layout_height="wrap_content"
          android:layout_width="wrap_content"
          android:id="@+id/my_image"/>

</LinearLayout>

In activity show your custom dialog box using below code - 在活动中使用以下代码显示您的自定义对话框 -

AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
LayoutInflater inflater = getActivity().getLayoutInflater();
View dialogView = inflater.inflate(R.layout.dialog, null);
builder.setView(dialogView)
                    .setPositiveButton(R.string.create, new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int which) {

                        }
                    })
                    .setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int which) {

                        }
                    }).create().show();

使用匹配父级中的imageview对新片段进行事务处理。

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

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