For the complete documentation index, see llms.txt. This page is also available as Markdown.

Customizing thumbnail slider in Android

ThumbnailSlider is a LinearLayout that contains an AppCompatSeekBar to change pages, and two AppCompatImageButton on the left and right side. When sliding the seekbar, it displays a small page preview on top of the thumbnail slider.

Show thumbnail slider

To set up your layout with the thumbnail slider, add a <ThumbnailSlider> element to your XML layout. For example, your layout may look like this:

Then, attach a PDFViewCtrl to the thumbnail slider. If PDFViewCtrl is in the same layout, you can set it by adding the app:pdfviewctrlId attribute:

If PDFViewCtrl is not in the same layout, you can programmatically set it to a thumbnail slider by calling setPdfViewCtrl(PDFViewCtrl):

Change thumbnail slider buttons

You can change the image drawable of the left menu item and right menu item buttons by adding the app:leftMenuItemDrawable and app:rightMenuItemDrawable attributes in your xml layout.

Example

Additionally, you can remove the left and right slider buttons by setting the drawables to null:

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.

Example

Thumbnail slider listeners

Buttons listener

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.

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:

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:

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:

For API >= 21:

Customize the thumb and progress bar

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.

Boolean

Last updated

Was this helpful?