Android 拍照并在ImageView中传递照片时,照片浮动错误?
我有一个按钮,当点击时,打开相机拍照,照片保存在SD卡中,当我在图像视图中将其传递到右侧时,我不明白为什么,有人能帮忙吗,我想在布局图的ImageView中显示照片的高度和重量,只有使用相机2使用相机1才有效我的意思是照片已保存但未显示在图像视图中代码在此处Android 拍照并在ImageView中传递照片时,照片浮动错误?,android,Android,我有一个按钮,当点击时,打开相机拍照,照片保存在SD卡中,当我在图像视图中将其传递到右侧时,我不明白为什么,有人能帮忙吗,我想在布局图的ImageView中显示照片的高度和重量,只有使用相机2使用相机1才有效我的意思是照片已保存但未显示在图像视图中代码在此处 Button takePhoto; ImageView photo; static final int Cam_Request = 1; @Override protected void onCreate(Bundle savedInst
Button takePhoto;
ImageView photo;
static final int Cam_Request = 1;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
photo = (ImageView)findViewById(R.id.ivPhoto);
takePhoto = (Button)findViewById(R.id.btnPhoto);
takePhoto.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent camera_intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
File file = getFile();
camera_intent.putExtra(MediaStore.EXTRA_OUTPUT,Uri.fromFile(file));
startActivityForResult(camera_intent,Cam_Request);
}
});
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
String path = "sdcard/camera_app/image.jpg";
photo.setImageDrawable(Drawable.createFromPath(path));
}
private File getFile()
{
File folder = new File("sdcard/camera_app");
if (!folder.exists())
{
folder.mkdir();
}
File image = new File(folder,"image.jpg");
return image;
}
}试试这个:
protected void onActivityResult(int requestCode, int resultCode, Intent data)
{
if (requestCode == CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE) {
if (resultCode == RESULT_OK) {
imageView = (ImageView) findViewById(R.id.imageView1);
Bitmap photo = (Bitmap) data.getExtras().get("data");
imageView.setImageBitmap(photo)
}}}
发布你的代码。没有人能猜到你的代码并帮你我已经完成了我的问题不是这是我想要的这是图标不是真正的尺寸,其次这不清楚我的意思是这个应用程序Crashet我不清楚你在说什么。请至少用英语说,我对我的语言感到抱歉,不管怎样,我已经解决了我的问题,