项目中需要用到拍摄身份证,拍完照片后直接拿到和身份证比例一致的图片,做成功的结果如下:
拍完照后直接拿到裁剪好的图本文的核心技术来自: https://yq.aliyun.com/articles/26706
先看看xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ffffff"
tools:context="business_android_client.croppercammer.MainActivity">
<business_android_client.croppercammer.ClipCamera
android:id="@+id/surface_view"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="center" />
<business_android_client.croppercammer.view.shadow
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
<TextView
android:id="@+id/tv_hint"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="请把身份证放入取景框,水平拍摄"
android:textColor="#fff"
android:rotation="90"
android:layout_centerInParent=&