如何解决使ImageView填充android中的所有AlertDialog
我在自定义的“警告对话框”中显示一个ImageView,但是alertDialog总是比图像视图大,并且正在显示某种页眉和页脚(imageView上方和下方的空白),这是最好的解决方案,使警报透视图与图像的宽度和高度匹配,并使图像填充整个警报对话框??
这是我的警报对话框的自定义布局:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="@+id/zoomed_image"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
</RelativeLayout>
这是我构建警报对话框的代码:
private void showImage(Bitmap bitmap) {
Dialog dialog = new Dialog(this);
View view = this.getLayoutInflater().inflate(R.layout.image_zoom_dialog,null);
dialog.setContentView(view);
AlertDialog.Builder builder = new AlertDialog.Builder(this);
LayoutInflater inflater = this.getLayoutInflater();
View alertDialogView = inflater.inflate(R.layout.image_zoom_dialog,null);
builder.setView(alertDialogView);
zoomed_image = alertDialogView.findViewById(R.id.zoomed_image);
zoomed_image.setImageBitmap(bitmap);
alertDialog = builder.create();
alertDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
alertDialog.setCancelable(true);
alertDialog.setCanceledOnTouchOutside(true);
alertDialog.getWindow().setLayout(bitmap.getWidth(),bitmap.getHeight());
alertDialog.show();
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。