Skip to content

简洁、高效的Android图片选择库,支持图片压缩、裁剪,支持多图选择

Notifications You must be signed in to change notification settings

CNCoderX/PhotoPicker

Repository files navigation

PhotoPicker

添加依赖关系

compile 'com.github.CNCoderX:PhotoPicker:1.0.1'

使用方法

添加权限
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
在Android7.0上添加FileProvider
// 在AndroidManifest.xml中添加
<provider
    android:name="android.support.v4.content.FileProvider"
    android:authorities="${applicationId}.provider"
    android:exported="false"
    android:grantUriPermissions="true">

        <meta-data
            android:name="android.support.FILE_PROVIDER_PATHS"
            android:resource="@xml/file_paths" />
</provider>

// 新建xml/file_paths.xml
<?xml version="1.0" encoding="utf-8"?>
<paths>
    <external-path name="external" path="DCIM"/>
</paths>
注册activity
<activity
    android:name="com.cncoderx.photopicker.ui.GalleryActivity"
    android:theme="@style/PhotoPickerTheme"
    android:screenOrientation="portrait"/>

<activity
    android:name="com.cncoderx.photopicker.ui.CropPhotoActivity"
    android:theme="@style/PhotoPickerTheme"
    android:screenOrientation="portrait"/>
在代码中添加
new PhotoPicker.Builder(this)
	.setMaxCount(maxCount)
	.setAspect(1, 1)
	.hideCamera(true)
	.circleCrop(true)
	.create(1);
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
	if (resultCode == RESULT_OK) {
	    ArrayList<IImage> images = data.getParcelableArrayListExtra(PhotoPicker.EXTRA_DATA);
	    ......
	}
}

About

简洁、高效的Android图片选择库,支持图片压缩、裁剪,支持多图选择

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages