Select Matisse themes
masterMatisse provides two built-in themes that can be applied when starting the activity:
R.style.Matisse_Zhihu: Light modeR.style.Matisse_Dracula: Dark mode
You can also define your own custom theme.
repository·master·Indexed 11 days ago
https://github.com/zhihu/matisseA local image and video selector library for Android supporting JPEG, PNG, GIF, MPEG, and MP4. Features include customizable themes, support for image engines like Glide and Picasso, custom filtering rules, and a builder-based configuration via Matisse.from().
Matisse provides two built-in themes that can be applied when starting the activity:
R.style.Matisse_Zhihu: Light modeR.style.Matisse_Dracula: Dark modeYou can also define your own custom theme.
Add jcenter() to your repositories and include the Matisse dependency in your dependencies block. Replace $latest_version with the desired version number.
repositories {
jcenter()
}
dependencies {
implementation 'com.zhihu.android:matisse:$latest_version'
}Matisse requires the following Android permissions to access media files:
android.permission.READ_EXTERNAL_STORAGEandroid.permission.WRITE_EXTERNAL_STORAGEIf your app targets Android 6.0 (API level 23) or higher, you must implement runtime permission requests before launching the Matisse selector.
Depending on which image engine you use, you must add specific rules to prevent warnings during the build process. Always include the rules required by your chosen engine (Glide or Picasso) first.
// If using Glide as the image engine
-dontwarn com.squareup.picasso.**
// If using Picasso as the image engine
-dontwarn com.bumptech.glide.**Use the Matisse.from() builder to configure and launch MatisseActivity. You can specify MIME types, selection limits, custom filters, image engines, and themes.
Matisse.from(MainActivity.this)
.choose(MimeType.allOf())
.countable(true)
.maxSelectable(9)
.addFilter(new GifSizeFilter(320, 320, 5 * Filter.K * Filter.K))
.gridExpectedSize(getResources().getDimensionPixelSize(R.dimen.grid_expected_size))
.restrictOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED)
.thumbnailScale(0.85f)
.imageEngine(new GlideEngine())
.showPreview(false) // Default is `true`
.forResult(REQUEST_CODE_CHOOSE);To get the list of selected media URIs, call Matisse.obtainResult(data) within your onActivityResult() callback, checking for the specific request code used to launch the selector.
List<Uri> mSelected;
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == REQUEST_CODE_CHOOSE && resultCode == RESULT_OK) {
mSelected = Matisse.obtainResult(data);
Log.d("Matisse", "mSelected: " + mSelected);
}
}