问题描述
我在自定义的“警告对话框”中显示一个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 (将#修改为@)