Coder Social home page Coder Social logo

kingtao / imageselector Goto Github PK

View Code? Open in Web Editor NEW

This project forked from smuyyh/imageselector

0.0 1.0 0.0 1.75 MB

Android 图片选择器。充分自由定制,简化使用,支持图库多选/单选/照片裁剪/拍照/自定义图片加载方式/自定义色调/沉浸式状态栏

Home Page: http://blog.csdn.net/yyh352091626/article/details/52154583

Java 100.00%

imageselector's Introduction

ImageSelector

Android 图片选择器。充分自由定制,支持图库多选/单选/图片裁剪/拍照/自定义图片加载库/沉浸式状态栏

依赖

dependencies {
    compile 'com.yuyh.imgsel:library:1.1.0'
}

版本

V1.1.0 增加自定义返回按钮图标及配置沉浸式状态栏选项

使用

配置权限

<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS" />

使用

// 自定义图片加载器
private ImageLoader loader = new ImageLoader() {
    @Override
    public void displayImage(Context context, String path, ImageView imageView) {
        // TODO 在这边可以自定义图片加载库来加载ImageView,例如Glide、Picasso、ImageLoader等
        Glide.with(context).load(path).into(imageView);
    }
};
// 自由配置选项
ImgSelConfig config = new ImgSelConfig.Builder(loader)
        // 是否多选
        .multiSelect(false)
        // “确定”按钮背景色
        .btnBgColor(Color.GRAY)
        // “确定”按钮文字颜色
        .btnTextColor(Color.BLUE)
        // 使用沉浸式状态栏
        .statusBarColor(Color.parseColor("#3F51B5"))
        // 返回图标ResId
        .backResId(android.support.v7.appcompat.R.drawable.abc_ic_ab_back_mtrl_am_alpha)
        // 标题
        .title("图片")
        // 标题文字颜色
        .titleColor(Color.WHITE)
        // TitleBar背景色
        .titleBgColor(Color.parseColor("#3F51B5"))
        // 裁剪大小。needCrop为true的时候配置
        .cropSize(1, 1, 200, 200)
        .needCrop(true)
        // 第一个是否显示相机
        .needCamera(false)
        // 最大选择图片数量
        .maxNum(9)
        .build();
        
// 跳转到图片选择器
ImgSelActivity.startActivity(this, config, REQUEST_CODE);
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    // 图片选择结果回调
    if (requestCode == REQUEST_CODE && resultCode == RESULT_OK && data != null) {
        List<String> pathList = data.getStringArrayListExtra(ImgSelActivity.INTENT_RESULT);
        for (String path : pathList) {
            tvResult.append(path + "\n");
        }
    }
}

imageselector's People

Contributors

smuyyh avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.