Android简单实现仿微信选择图片以及拍照(PhotoPicker)

实现仿微信的图片选择,预览以及拍照,属性可以设置显示照相机以及预览时是否显示删除按钮等,功能齐全并且可以根据存储照片的路径进行修改等

Gradle配置

dependencies {

    compile 'me.iwf.photopicker:PhotoPicker:0.9.5@aar'
    
    compile 'com.android.support:appcompat-v7:23.4.0'
    compile 'com.android.support:recyclerview-v7:23.4.0'
    compile 'com.android.support:design:23.4.0'
    compile 'com.nineoldandroids:library:2.4.0'
    compile 'com.github.bumptech.glide:glide:3.7.0'
}
  • appcompat-v7version >= 23.0.0

选择图片

PhotoPicker.builder()
        .setPhotoCount(9)
        .setShowCamera(true)
        .setShowGif(false)
        .setPreviewEnabled(true)
        .setSelected(photos)
        .start(PhotoActivity.this, PhotoPicker.REQUEST_CODE);

 

预览图片

 
PhotoPreview.builder() .setPhotos(photos) .setCurrentItem(0) .setShowDeleteButton(true) .start(PhotoActivity.this,PhotoPicker.REQUEST_CODE );

onActivityResult方法里代码

 
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (requestCode == PhotoPicker.REQUEST_CODE) { if (data != null) { photos = data.getStringArrayListExtra(PhotoPicker.KEY_SELECTED_PHOTOS); for (int i=0;i

manifest配置,权限以及Activity(三方封装方法)


    
    
    
  
    ...
    
    

    
    
  

Custom style配置



 

你可能感兴趣的:(Androidの图片处理集)