【发布时间】:2016-09-30 17:31:53
【问题描述】:
我不完全明白我的问题出在哪里,所以我会提供尽可能多的信息,其中一些可能与找到答案无关,但其中一些可能会有所帮助。
问题
我已将相机集成到我的应用程序中,我正在使用 surfaceView 来显示相机的预览,在捕获图像时我获取原始图像字节和通过 ObjectOutput 流发送它们,我将在该流中显示该活动的图像。这是该代码的 sn-p:
out = new ObjectOutputStream(new FileOutputStream(new File(getActivity().getCacheDir(),"")+"cacheFile.srl"));
out.writeObject(bytes);
在另一个活动中,我读取字节并显示图像:
bytes = (byte[]) in.readObject();
image = BitmapFactory.decodeByteArray(bytes, 0, bytes.length);
myHolder.setImageBitmap(image);
这是显示图像的活动的 XML 文件:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".fragments.Home">
<ImageView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:id="@+id/ih"
android:layout_alignParentTop="true"
android:layout_alignParentRight="true"
android:layout_alignParentLeft="true"
android:layout_alignParentBottom="true"/>
如果需要任何其他信息,请告诉我并更新帖子
更新 1
我将布局更改为:
<ImageView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:scaleType="centerCrop"
android:id="@+id/ih"
android:layout_alignParentTop="true"
android:layout_alignParentRight="true"
android:layout_alignParentLeft="true"
android:layout_alignParentBottom="true"
android:layout_marginBottom="100dp"/>
但我的两边还是有白线
【问题讨论】:
-
了解
ImageView的scaleTypes -
请问您能分享一下图片和您的设备的分辨率吗?
标签: java android xml android-layout bitmap