diff --git a/README.md b/README.md index 6138912..40d3f41 100644 --- a/README.md +++ b/README.md @@ -96,6 +96,39 @@ builder.setCustomImageRequestBuilder( .setPostprocessor(new GrayscalePostprocessor())); ``` +#### Custom theme +You can also apply your own theme to the viewer: +```java +builder.setCustomTheme(R.style.MyCustomTheme); +``` +You could, for example, provide an exit/enter animation to the viewer by declaring `MyCustomTheme` like this: +```xml + + + +``` +**fade_in.xml:** +```xml + + +``` +**fade_out.xml:** +```xml + + +``` + #### Image margin Simply add margins between images with dimens with setImageMargin(context, dimen) or in `px` using `setImageMarginPx(marginPx)`. diff --git a/frescoimageviewer/src/main/java/com/stfalcon/frescoimageviewer/ImageViewer.java b/frescoimageviewer/src/main/java/com/stfalcon/frescoimageviewer/ImageViewer.java index 4032f4c..3cb6648 100644 --- a/frescoimageviewer/src/main/java/com/stfalcon/frescoimageviewer/ImageViewer.java +++ b/frescoimageviewer/src/main/java/com/stfalcon/frescoimageviewer/ImageViewer.java @@ -89,7 +89,7 @@ public void onPageSelected(int position) { } }); - dialog = new AlertDialog.Builder(builder.context, getDialogStyle()) + dialog = new AlertDialog.Builder(builder.context, builder.customTheme == 0 ? getDialogStyle() : builder.customTheme) .setView(viewer) .setOnKeyListener(this) .create(); @@ -211,6 +211,7 @@ public static class Builder { private boolean shouldStatusBarHide = true; private boolean isZoomingAllowed = true; private boolean isSwipeToDismissAllowed = true; + private @StyleRes int customTheme; /** * Constructor using a context and images urls array for this builder and the {@link ImageViewer} it creates. @@ -354,7 +355,8 @@ public Builder setContainerPadding(Context context, @DimenRes int padding) { } /** - * Set status bar visibility. By default is true. + * Set status bar visibility. By default is true.
+ * It is ignored if {@link #setCustomTheme(int)} was used. * * @return This Builder object to allow for chaining of calls to set methods */ @@ -416,6 +418,18 @@ public Builder setCustomDraweeHierarchyBuilder(GenericDraweeHierarchyBuilder cus return this; } + /** + * Set a custom theme for the viewer. + * Using a custom theme will make the viewer ignore the value set with {@link #hideStatusBar(boolean)}. + * You can still have it hidden by extending your custom theme from {@code Theme.Translucent.NoTitleBar.Fullscreen}. + * + * @return This Builder object to allow for chaining of calls to set methods + */ + public Builder setCustomTheme(@StyleRes int theme) { + this.customTheme = theme; + return this; + } + /** * Creates a {@link ImageViewer} with the arguments supplied to this builder. It does not * {@link ImageViewer#show()} the dialog. This allows the user to do any extra processing