How to Change the Color of the Overflow Button in the Main Toolbar

When the main toolbar is full, some actions could end up in the overflow menu. By default, the overflow button is white, but the code below demonstrates how to change this default color to better fit your theme.

Changing the Color Programmatically

The overflow button color can be changed programmatically inside your activity:

val mainToolbar = findViewById(R.id.pspdf__toolbar_main) as MainToolbar
mainToolbar.overflowIcon?.colorFilter = PorterDuffColorFilter(color, PorterDuff.Mode.SRC_ATOP)

Changing the Color in the Theme

You can also change the overflow button color in your activity theme:

<!-- Set a custom style for the overflow button in your theme. -->
<item name="android:actionOverflowButtonStyle">@style/OverflowButtonStyle</item>

....

<!-- Extend the overflow button style with a different tint color. -->
<style name="OverflowButtonStyle" parent="Widget.AppCompat.ActionButton.Overflow">
    <item name="tint">@color/custom_overflow_button_color</item>
</style>

If you aren’t yet using a custom theme, refer to our guide on defining a custom theme for more information.