Android调用系统摄像头拍照并显示在ImageView上
发布时间:2020-10-03 00:05:03
来源:脚本之家
阅读:235
作者:CSDN_陈诚
简介
现在市面上的apk只要涉及用户中心都会有头像,而且这个头像也是可自定义的,有的会采取读取相册选择其中一张作为需求照片,另一种就是调用系统摄像头拍照并获取即时照片,本博文就是讲述如何调用摄像头拍照并显示在指定的控件上。
先来看看效果图
由于这里我用的是模拟器没有摄像头,所以拍照是黑的,至于里面2个红色圆圈那是Genymotion自带的标志。
实现起来比较简单:
activity_main.xml
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"
android:orientation="vertical"
tools:context="