Camera库可以将相机功能以Material Design的方式呈现,可以提升界面观感和使用体验。
官方文档:https://github.com/commonsguy/cwac-camera
Camera库的安装很简单。只需在 <project>/app/build.gradle中添加新的maven repository和依赖:
- repositories {
- maven {
- url "https://.com.s3.amazonaws.com/repo.commonsware.com"
- }
- }
- //...
- dependencies {
- //...
- compile 'com.commonsware.cwac:camera:0.6.12'
- }
最后需要在 AndroidManifest.xml 文件中添加新的权限:
- <?xml version="1.0" encoding="utf-8"?>
- <manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="io.github.froger.instamaterial">
- <!--...-->
- <uses-permission android:name="android.permission.CAMERA" />
- <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
- <uses-feature
- android:name="android.hardware.camera"
- android:required="true" />
- <uses-feature
- android:name="android.hardware.camera.front"
- android:required="false" />
- <uses-feature
- android:name="android.hardware.camera.autofocus"
- android:required="false" />
- <application
- android:name=".InstaMaterialApplication"
- android:icon="@drawable/ic_launcher"
- android:label="@string/app_name"
- android:theme="@style/AppTheme">
- <!--...-->
- </application>
- </manifest>