我应该在我的应用程序中有一个DialogFragment。这个片段的目的是显示放大的图片,如果我点击其他片段中的缩略图。在运行时调整DialogFragment的大小
这里的布局吧:
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout 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="wrap_content"
android:layout_height="wrap_content"/>
</FrameLayout>
因此,基本上,这个ImageView的应该显示在PIC的放大,我想显示PIC尽可能地在屏幕上。
我有一个位图,我可以根据屏幕的尺寸计算出适合屏幕的显示尺寸。
问题:的问题是在显示的缩放PIC的额外空间:
我不能“作物“这个额外的空间。我读了解决调整大小和我做了以下内容:(调用mPhotoView.setImageBitmap(bitmap)
其中mPhotoView是我从findViewById()
得到了ImageView的实例之前)
BitmapFactory.Options options = new BitmapFactory.Options();
options.inJustDecodeBounds = true;
BitmapFactory.decodeFile(getArguments().getString(key_imagePath), options);
float srcWidth = options.outWidth;
float srcHeight = options.outHeight;
FrameLayout.LayoutParams p = new FrameLayout.LayoutParams((int)srcWidth, (int)srcHeight);
view.setLayoutParams(p);
view.requestLayout();
问:
- 我如何删除这个多余的来自DialogFragment视图的空白空间?
- 做一个DialogFragment是不是意味着布局的大小会被修正或者总体上会有像这样的意见?
- 是否有可能是因为布局传递?
你的框架布局XML具有'match_parent'与'wrap_content'尝试删除空白。 –
@MarkKeen:我正在尝试。谢谢。 –
@MarkKeen:它不适用于wrap_content –