Frameworks
React Native
Flutter
Package samples
Cookbook
Version 11
Version 10
Version 9
Version 8
Version 7
Version 6
Version 5
There are a few themes which can be adjusted to change the output color mode.
AppCompat has a new theme called DayNight
since Support Lib 23.2.0. So, if your activity's theme extends from one of the DayNight variants then you can switch between dark theme and light theme in your activity as follows.
As you can see, to take any effect for changing night mode the activity should be re-created.
For example, in our DocumentActivity
, we change the device UI night mode when the PDFViewCtrl's color mode is updated:
You can also have different styles for device day/night modes by creating new resources for night. This involves adding a new directory to the resources folder, using the night qualifier, to re-define the resources. In the following example, primary colors and accent color are different in day and night mode:
res/values/styles.xml
res/values-night/styles.xml
PDFViewCtrl
has three special color modes: night mode, inverted color mode, and custom color mode. In night mode, colors are adjusted to improve reading at night, in inverted color mode, all colors are inverted, and in custom color mode, you can set a custom color for text and the background color.
Color modes from left to right: normal color mode, inverted color mode, night mode and custom color mode.
To set the color mode:
Color mode | Constant value |
---|---|
Normal color mode | |
Night mode | |
Inverted color mode | |
Custom color mode |
setColorPostProcessMode(int)
.PDFViewCtrl
background color for the best visual result. You can set background color by calling setClientBackgroundColor(int, int, int, boolean)
.For example, set the background color to black for night mode:postprocess_gradient_map
, call PDFViewCtrl.setColorPostProcessColors(int, int)
to set the white and black points. For example, for a sepia effect, try:PDFViewCtrl
to redraw the contents:Sample result when using postprocess_gradient_map
and a light/dark brown for the white/black color: The example below shows all of this functionality being used to set up a custom color mode for PDFViewCtrl
:Result:Alternatively, you can also set custom color mode by adding a gradient map image as follows:
.png
image to your project res/raw
folder.For example, add the following image to res/raw
folder and name it custom_mode_filter.png
:To learn more about res/raw resource directory, see Providing Resources
MappedFile
:mappedFile
created above to PDFViewCtrl
by calling PDFViewCtrl.setColorPostProcessMapFile(Filter)
.Where pdfViewCtrl
is an instance of PDFViewCtrl
.PDFRasterizer.e_postprocess_gradient_map
to pdfViewCtrl
by calling pdfViewCtrl.setColorPostProcessMode(int)
. Then update pdfViewCtrl
:Result:
Did you find this helpful?
Trial setup questions?
Ask experts on DiscordNeed other help?
Contact SupportPricing or product questions?
Contact Sales