-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Basic Usage
Matisse.from(MainActivity.this)
.choose(MimeType.ofAll(), false)
.countable(true)
.maxSelectable(9)
.gridExpectedSize(getResources().getDimensionPixelSize(R.dimen.grid_expected_size))
.restrictOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED)
.thumbnailScale(0.85f)
.imageEngine(new GlideEngine())
.forResult(REQUEST_CODE_CHOOSE);
In onActivityResult()
callback of the starting Activity
or Fragment
:
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == REQUEST_CODE_CHOOSE && resultCode == RESULT_OK) {
Log.d("Matisse", "Uris: " + Matisse.obtainResult(data));
Log.d("Matisse", "Paths: " + Matisse.obtainPathResult(data));
Log.e("Matisse", "Use the selected photos with original: "+String.valueOf(Matisse.obtainOriginalState(data)));
}
}
Matisse supports the following mime types:
Mime type | File extensions | Media type |
---|---|---|
image/jpeg | jpg, jpeg | image |
image/png | png | image |
image/gif | gif | image |
image/x-ms-bmp | bmp | image |
image/webp | webp | image |
video/mpeg | mpeg, mpg | video |
video/mp4 | mp4, m4v | video |
video/quicktime | mov | video |
video/3gpp | 3gp, 3gpp | video |
video/3gpp2 | 3g2, 3gpp2 | video |
video/x-matroska | mkv | video |
video/webm | webm | video |
video/mp2ts | ts | video |
video/avi | avi | video |
All images and videos will be shown in Matisse by default, you can't limit the selectable mime types by:
MimeType.ofAll()
MimeType.of(MimeType type, MimeType... rest)
MimeType.ofImage()
MimeType.ofVideo()
You can request Matisse to show only one media type if
- invoke
showSingleMediaType(true)
when launching Matisse - Choosing only images or videos
You can launch Matisse from Activity or Fragment. Meanwhile you should receive results in the corresponding onActivityResult()
callback.
There will be a check mark in the right top corner of the thumbnail and you can't only select one image.
Use countable(true)
to show an auto-increased number check mark from 1. It's like the Dracula Style screenshot in README.
Use maxSelectable(int maxSelectable)
to limit maximum selectable number.
Use restrictOrientation(@ScreenOrientation int orientation)
to set the desired orientation of image selecting and previewing Activity.
If you want a fixed span count, use spanCount(int spanCount)
. The span count will stay the same when orientation changes.
If you expect a grid size which will be flexible fitting different screens, use spanCount(int spanCount)
. This value won't necessarily be applied cause the photo grid should fill the view container. The measured photo grid's size will be as close to this value as possible.
Use thumbnailScale(float scale)
to set thumbnail bitmap's scale compared to the view's size. It should be a float value in (0.0, 1.0].
- Use
originalEnable(boolean enable)
to set whether to use select original photo feature .If true you can see a check-original checkbox at bottomToolbar. - Use
maxOriginalSize(int size)
to set maximum original size ,the unit is MB
Use CaptureStrategy(boolean isPublic, String authority, String directory)
can custom a sub directory for capture feature
Use autoHideToolbarOnSingleTap(boolean enable)
to enable this feature