You can also change the buttons programmatically by calling setMenuItem(@DrawableRes int, @MenuItemPosition int). The second parameter determines the position of the button which is either POSITION_LEFT or POSITION_RIGHT.
You can add a menu item clicked event listener by calling setOnMenuItemClickedListener to be notified when one of the left or right buttons is clicked.
2 if (menuItemPosition == ThumbnailSlider.POSITION_LEFT) {
3 // The left button was clicked.
4 } else {
5 // The right button was clicked.
6 }
7}
Seekbar listener
You can set a thumbnail slider seekbar event listener by calling setThumbSliderListener to be notified when thumbnail slider touch tracking has started/stopped:
2 override fun onThumbSliderStartTrackingTouch() {
3 // Called when tracking on the seekbar has started
4 }
5
6 override fun onThumbSliderStopTrackingTouch(pageNum: Int) {
7 // Called when tracking on the seekbar has stopped
8 }
9})
Appearance style
Customize slider colors
You can customize the color of the left and right menu buttons as well as the seekbar by setting a custom style to the thumbnail_slider attribute in your apps's theme. The custom style must extend ThumbnailSliderStyle. For example:
XML
1<style name="PDFTronAppTheme" parent="PDFTronAppThemeBase"> <item name="colorPrimary">@color/app_color_primary_day</item> <item name="colorPrimaryDark">@color/app_color_primary_dark_day</item> <item name="colorAccent">@color/app_color_accent</item> <!-- Set your custom style in your app theme --> <item name="thumbnail_slider">@style/CustomThumbnailSliderStyle</item> </style>
2
3<style name="CustomThumbnailSliderStyle" parent="ThumbnailSliderStyle"> <!-- Change the background color of the slider--> <item name="colorBackground">@android:color/red</item> <!-- Change the color of the seekbar and seekbar icon in the slider--> <item name="seekbarColor">@android:color/black</item> <!-- Change the color of the menu button left of the slider --> <item name="leftMenuItemColor">@android:color/black</item> <!-- Change the color of the menu button right of the slider --> <item name="rightMenuItemColor">@android:color/black</item> <!-- Change the description of the menu button left of the slider --> <item name="leftMenuItemContentDescription">"LeftDescription"</item> <!-- Change the color of the menu button right of the slider --> <item name="rightMenuItemContentDescription">"RightDescription"</item> <!-- Change the icon of the menu button left of the slider --> <item name="leftMenuItemDrawable">@drawable/ic_thumbnails_grid_black_24dp</item> <!-- Change the icon of the menu button right of the slider --> <item name="rightMenuItemDrawable">@drawable/ic_list_white_24dp</item> </style>
Customize seekbar attributes
If you want to further customize the seekbar's layout attributes and appearance, such as padding and height, you can override the default seekbar style R.style.ThumbnailSliderStyle.Seekbar by declaring the following in res/values/styles.xml:
Example
For API < 21:
Java
1<style name="ThumbnailSliderStyle.Seekbar" parent="Widget.AppCompat.SeekBar" > <!-- add paddingTop and paddingBottom for api < 21 here for avoiding seekbar becomes too thick--> <item name="android:paddingTop">16dp</item> <item name="android:paddingBottom">16dp</item> <item name="android:minHeight">2dp</item> <item name="android:maxHeight">2dp</item> <item name="android:layout_gravity">center</item> </style>
The seekbar progress bar drawable can be customized by overriding the seek_track_material.xml drawable file. Similarly, the seekbar thumbnail drawable can be changed by overriding the seek_thumb.xml drawable file. For reference, the source code for these drawables can be found in the lib\src\PDFViewCtrlTools\res\drawable folder of the SDK package.
XML attributes
Attribute
Description
Format
app:pdfviewctrlId
Specifies the PDFViewCtrl view id
Reference
app:leftMenuItemContentDescription
Specifies the content description of left menu item.
String
app:rightMenuItemContentDescription
Specifies the content description of right menu item.
String
app:leftMenuItemDrawable
Specifies left menu item drawable resource.
Reference
app:rightMenuItemDrawable
Specifies right menu item drawable resource.
Reference
app:colorBackground
Specifies background color. Uses default system background color if not defined.
Color
app:seekbarColor
Specifies seekbar progress bar and thumb color.
Default value: ?attr/colorPrimary in day mode and @android:color/white in night mode.
Color
app:leftMenuItemColor
Specifies left menu item color.
Default value: ?attr/colorPrimary in day mode and @android:color/white in night mode.
Color
app:rightMenuItemColor
Specifies right menu item color.
Default value: ?attr/colorPrimary in day mode and @android:color/white in night mode.
Color
app:shadowEnabled
Specifies whether the shadow will appear. Default value: true.