GithubHelp home page GithubHelp logo

liangzuan1983 / sketch-android Goto Github PK

View Code? Open in Web Editor NEW

This project forked from panpf/sketch

0.0 1.0 0.0 245.01 MB

Sketch 是 Android 上一个强大且全面的图片加载器,支持 GIF,手势缩放以及分块显示超大图片。Sketch is a powerful and comprehensive image loader on Android, with support for GIF, gesture zooming, block display super large image

License: Apache License 2.0

Kotlin 1.53% Java 98.47%

sketch-android's Introduction

logo_image Sketch Image Loader

Platform Android Arsenal License API QQ Group

English version of the README.md

Sketch 是 Android 上一款强大且全面的图片加载器,除了图片加载的必备功能外,还支持 GIF,手势缩放、分块显示超大图片、自动纠正图片方向、显示视频缩略图等功能

示例 APP

sample_app_download_qrcode

扫描二维码下载或点我下载

特性

支持的特性

  • 多种 URI 支持. 支持 http://https://asset://content://file:///sdcard/sample.jpg/sdcard/sample.jpgdrawable://data:image/data:img/android.resource://apk.icon://app.icon:// 等 URI,通过 UriModel 还可以扩展支持的 URI
  • 支持 gif 图片. 集成了 android-gif-drawable 1.2.10 可以方便的显示 gif 图片
  • 支持手势缩放. 支持手势缩放功能,在 PhotoView 的基础上进行了优化,增加了滚动条,定位等功能
  • 支持分块显示超大图. 支持分块显示超大图功能,从此再大的图片也不怕了
  • 支持三级缓存. 通过 LruMemoryCache、LruDiskCache 复用图片,加快显示时间;通过 LruBitmapPool 复用 Bitmap,减少因 GC 而造成的卡顿
  • 支持纠正图片方向. 可纠正方向不正的图片,并且分块显示超大图功能也支持,仅限 JPEG 格式的图片
  • 支持显示 APK 或 APP 图标. 支持显示本地 APK 文件的图标或根据包名和版本号显示已安装APP的图标
  • 支持 Base64 图片. 支持解析 Base64 格式的图片
  • 支持各种列表. 在各种列表(ListView、RecyclerView)中循环使用不错位,并且不占用 setTag() 方法
  • 自动防止加载过大 Bitmap 可通过 maxSize 来控制加载到内存的图片的尺寸,默认为 ImageView的 layout_width 和 layout_height 或屏幕的宽高
  • 独家 TransitionDrawable 支持. 独家支持任意尺寸的两张图片使用 TransitionDrawable 过渡显示,保证不变形
  • 只加载或只下载. 除了 display() 方法可以显示图片之外,你还可以通过 load() 方法只加载图片到内存中或通过 download() 方法只下载图片到本地
  • 移动数据下暂停下载. 内置了移动数据下暂停下载图片的功能,你只需开启即可
  • 自动选择合适的 Bitmap.Config. 根据图片的 MimeType 自动选择合适的 Bitmap.Config,减少内存浪费,例如对于 JPEG 格式的图片就会使用 Bitmap.Config.RGB_565 解码
  • 强大且灵活的自定义. 可自定义 URI 支持、HTTP、下载、缓存、解码、处理、显示、占位图等各个环节

支持的 URI

Type Scheme
File in network http://, https://
File in SDCard /, file://
Content Resolver content://
Asset Resource asset://
Drawable Resource drawable://
Base64 data:image/, data:/img/
APK Icon apk.icon://
APP Icon app.icon://
Android Resource android.resource://

详情请参考 URI 类型及使用指南

支持的图片类型

  • jpeg
  • png
  • gif
  • bmp
  • webp

开始使用

导入 Sketch

在 app 的 build.gradle 文件的 dependencies 节点中加入依赖

compile 'me.panpf:sketch:$sketch_version'

请自行替换 $sketch_version 为最新的版本 sketch_version_image (不要"v")

如果需要播放 GIF 就添加 sketch-gif 的依赖

compile 'me.panpf:sketch-gif:$sketch_gif_version'

请自行替换 $sketch_gif_version 为最新的版本 sketch_gif_version_image (不要"v")

Android Studio 会自动合并 AAR 中所包含的权限和混淆配置

使用 SketchImageView 显示图片

SketchImageView sketchImageView = (SketchImageView) findViewById(R.id.image_main);
sketchImageView.displayImage("http://t.cn/RShdS1f");

文档

基础功能:

提升用户体验:

更多:

更新日志

Please view the CHANGELOG.md file

特别感谢

交流群

  • QQ Group

License

Copyright (C) 2017 Peng fei Pan <[email protected]>

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

  http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

sketch-android's People

Contributors

panpf avatar

Watchers

James Cloos 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.