任何人都可以告诉如何在androidvIEw中使用前置摄像头拍摄的照片中显示图片任何人都可以提供代码
谢谢
解决方法:
这是代码试试吧
这是我的xml文件
<?xml version="1.0" enCoding="utf-8"?><linearLayout xmlns:androID="http://schemas.androID.com/apk/res/androID" androID:orIEntation="vertical" androID:layout_wIDth="fill_parent" androID:layout_height="fill_parent" androID:ID="@+ID/linear"> <button androID:ID="@+ID/btn" androID:layout_wIDth="200dp" androID:layout_height="wrap_content" androID:text="Click" /> <ImageVIEw androID:ID="@+ID/img_prevIEw" androID:layout_wIDth="fill_parent" androID:layout_height="fill_parent" /></linearLayout>
这是活动代码
button btn;int CAMERA_PIC_REQUEST = 0;ImageVIEw imgVIEw;imgVIEw = (ImageVIEw) findVIEwByID(R.ID.img_prevIEw); btn = (button) findVIEwByID(R.ID.btn); btn.setCompoundDrawables(null, getResources().getDrawable(R.drawable.icon), null, null); btn.setonClickListener(new OnClickListener() { @OverrIDe public voID onClick(VIEw v) { Intent camera_intent = new Intent(androID.provIDer.MediaStore.ACTION_IMAGE_CAPTURE); startActivityForResult(camera_intent, CAMERA_PIC_REQUEST); } });
这是onActivityResult
@OverrIDeprotected voID onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); switch(requestCode){ case CAMERA_PIC_REQUEST: if(resultCode==RESulT_OK){ Bitmap thumbnail = (Bitmap) data.getExtras().get("data"); imgVIEw.setimageBitmap(thumbnail); } }}
总结 以上是内存溢出为你收集整理的如何在android中的相机拍摄的imageview照片中显示图片全部内容,希望文章能够帮你解决如何在android中的相机拍摄的imageview照片中显示图片所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)