我初始化使用无法设置的ImageView android系统
iv = (ImageView)findViewById(R.id.ivPic);
相机拍摄的PIC在这之后的ImageView的。在onActivityResult(int requestCode, int resultCode, Intent data)
方法中,我正在做以下设置ImageView。
Bitmap bmpEmail = BitmapFactory.decodeFile(out.getAbsolutePath());
iv.setImageBitmap(bmpEmail);
我只是一个空白的屏幕。当应用程序启动时,屏幕的布局是这样的:
当我拍照时,屏幕会变形,我不知道为什么会发生这种情况。
PS:我已经增加了第二张图片的大小,使按钮是可见的,如果你看到这些按钮的尺寸已经缩小了不少与ImageView的占位符似乎占用了大部分的屏幕空间而不显示图像视图。
我已经发布我下面的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" android:weightSum="100">
<ImageView
android:id="@+id/ivPic"
android:layout_width="match_parent" android:layout_height="wrap_content"
android:layout_gravity="center" android:src="@drawable/ic_launcher"
android:layout_weight="60"/>
<ImageButton
android:id="@+id/ibPic"
android:layout_width="match_parent" android:layout_height="wrap_content"
android:layout_gravity="center" android:src="@drawable/ic_launcher"
android:layout_weight="20" />
<Button
android:id="@+id/bPic"
android:layout_width="match_parent" android:layout_height="wrap_content"
android:layout_gravity="center" android:text="Email Pic"
android:layout_weight="20" />
</LinearLayout>
您是否在bmpEmail中获得位图? –
是的,我得到的价值'bmpEmail >> android.graphics.Bitmap @ 410b8760' – misguided
,因为你的解码位图大小和你的'ImageView'高度'wrap_content',所以尺寸增加。要么给定尺寸或使用'layout_weight'来正确格式化。 –