Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
A

Album

> 开发工具
Open source

:watermelon: Album and Gallery for Android platform.

2.5K stars0 likes1 views
WebsiteGitHub

About

:watermelon: Album and Gallery for Android platform.

Album

Album is a Material Design style album, it provides three functions: album, camera and gallery.

  1. Select images, selecte videos, or select pictures and videos.
  2. Take a picture, record a video, or use camera in album list.
  3. Preview pictures and videos in the gallery or select pictures and videos in the gallery.

Screenshot

White StatusBar, the left is the effect of 5.0-(Containing 5.0), the right is the effect of 6.0+(Containing 6.0):

Effect on landscape screen:

Download

groovy
implementation 'com.yanzhenjie:album:2.1.3'

Usage

Developers must configure AlbumLoader to make Album work normally, and AlbumLoader is used to load thumbnails of images and videos.

This is an example:

java
public class MediaLoader implements AlbumLoader {

    @Override
    public void load(ImageView imageView, AlbumFile albumFile) {
        load(imageView, albumFile.getPath());
    }

    @Override
    public void load(ImageView imageView, String url) {
        Glide.with(imageView.getContext())
                .load(url)
                .error(R.drawable.placeholder)
                .placeholder(R.drawable.placeholder)
                .crossFade()
                .into(imageView);
    }
}

The example uses Glide to load thumbnails of pictures and videos. Please remember to configure the AlbumLoader you just implemented.

java
Album.initialize(AlbumConfig.newBuilder(this)
    .setAlbumLoader(new MediaLoader())
    ...
    .build());

Image and video mix options

…

Image Selection

…

If developer want to crop the image, please use Durban.

Video Selection

…

Take Picture

java
Album.camera(this) // Camera function.
    .image() // Take Picture.
    .filePath() // File save path, not required.
    .onResult(new Action<String>() {
        @Override
        public void onAction(@NonNull String result) {
        }
    })
    .onCancel(new Action<String>() {
        @Override
        public void onAction(@NonNull String result) {
        }
    })
    .start();

If developer want to crop the image, please use Durban.

Record Video

java
Album.camera(this)
    .video() // Record Video.
    .filePath()
    .quality(1) // Video quality, [0, 1].
    .limitDuration(Long.MAX_VALUE) // The longest duration of the video is in milliseconds.
    .limitBytes(Long.MAX_VALUE) // Maximum size of the video, in bytes.
    .onResult(new Action<String>() {
        @Override
        public void onAction(@NonNull String result) {
        }
    })
    .onCancel(new Action<String>() {
        @Override
        public void onAction(@NonNull String result) {
        }
    })
    .start();

Gallery

java
// Preview AlbumFile:
Album.galleryAlbum(this)
...

// Preview path:
Album.gallery(this)
    .checkedList(imageList) // List of image to view: ArrayList<String>.
    .checkable(true) // Whether there is a selection function.
    .onResult(new Action<ArrayList<String>>() { // If checkable(false), action not required.
        @Override
        public void onAction(@NonNull ArrayList<String> result) {
        }
    })
    .onCancel(new Action<String>() {
        @Override
        public void onAction(@NonNull String result) {
        }
    })
    .start();

If checkable(false), listener not required, the CheckBox and the FinishButton will be not appear.

The user may click or long press on the preview image and the developer can listen to both events:

java
Album.gallery(this)
    ...
    .itemClick(new ItemAction<String>() {
        @Override
        public void onAction(Context context, String item) {
        }
    })
    .itemLongClick(new ItemAction<String>() {
        @Override
        public void onAction(Context context, String item) {
        }
    })
    .start();

Capabilities of AlbumFile

AlbumFile is the result of the selection of images and videos, The properties of the image and video are different, and their different attributes are listed below.

Image

…

Video

…

Customize UI

Through Widget, developer can configure the title, color of StatusBar, color of NavigationBar and so on.

java
// Such as image video mix:
 Album.album(this)
    .multipleChoice()
    .widget(...)
    ...

// Image selection:
Album.image(this)
    .multipleChoice()
    .widget(...)
    ...

// Video selection:
Album.video(this)
    .multipleChoice()
    .widget(...)
    ...

// Gallery, preview AlbumFile:
Album.galleryAlbum(this)
    .widget(...)
    ...

// Gallery, preview path:
Album.gallery(this)
    .widget(...)
    ...

So we only need to pass in a Widget parameter just fine:

…

Configuration language

Album defaults to English and changes with the system language. Unfortunately, Album only supports English, Simplified Chinese, Traditional Chinese and Portuguese. However, developers can copy the items in Album's string.xml into your project for translation, the best thing is that you can contribute and submit pull requests to perfect Album.

Developers can specify Album's language:

java
Album.initialize(AlbumConfig.newBuilder(this)
    ...
    .setLocale(Locale.ENGLISH)
    .build());

Contributing

Before submitting pull requests, contributors must abide by the agreement .

Proguard-rules

If you are using ProGuard you might need to add the following options:

txt
-dontwarn com.yanzhenjie.album.**
-dontwarn com.yanzhenjie.mediascanner.**

License

Copyright 2017 Yan Zhenjie

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.

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

Javaalbumcameragalleryimage

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
Category开发工具
PricingOpen source

> Related tools

V
VS Code
流行的开源代码编辑器
G
Git
分布式版本控制系统
V
Vite
下一代前端构建工具