PDFTron Dialogs buttons are invisible

Product: native android sdk

Product Version: 9.3.1

Please give a brief summary of your issue:
Button in dialogs are invisible

Please describe your issue and provide steps to reproduce it:
Open up AlertDIalogs or Date dialogs and buttons are invisible


I’ve set these attributes in our theme but to know avail.


<style name="AlertDialogTheme" parent="Theme.AppCompat.Light.Dialog.Alert">
        <item name="colorPrimary">@color/colorPrimary</item>
        <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
        <item name="colorAccent">@color/colorAccent</item>
        <item name="buttonBarButtonStyle">@style/DialogButtonStyle</item>
    </style>

    <style name="DialogButtonStyle" parent="@style/Widget.AppCompat.Button.ButtonBar.AlertDialog">
        <item name="android:textColor">@color/colorPrimary</item>
    </style>

Please provide a link to a minimal sample where the issue is reproducible:

Hello, I’m Ron, an automated tech support bot :robot:

While you wait for one of our customer support representatives to get back to you, please check out some of these documentation pages:

Guides:APIs:Forums:

I was looking at this post but couldn’t figure out which attributes in the theme resolved the issue. More specific guidance as to which items resolve the issue would be much appreciated :slight_smile:

Hi @seth.pacheco,

I tried to reproduce your issue with the date picker, but couldn’t see any missing buttons in the date picker.

Would you be able to provide a sample project that replicates this issue?

Hi Seth,

This should be fixed if the following styles extend Theme.MaterialComponents.Light.NoActionBar.Bridge

<style name="AppTheme" parent="Theme.MaterialComponents.Light.NoActionBar.Bridge">
 <style name="AppThemeNoToolbar" parent="Theme.MaterialComponents.Light.NoActionBar.Bridge">

Please let us know if this resolves your issue.

Best Regards,
Eamon

1 Like

Yep, that fixed it. Thank you

1 Like

Hey @emallon!

After further testing our app changing our theme to inherit from

<style name="AppTheme" parent="Theme.MaterialComponents.Light.NoActionBar.Bridge">
 <style name="AppThemeNoToolbar" parent="Theme.MaterialComponents.Light.NoActionBar.Bridge">

It has actually messed up many areas inside our app. I’m pretty confused with this issue because it looks as though your code calling the DatePicker is just using Android’s default DatePickerDialog.

I have implemented a popup of the DatePickerDialog on app launch and it shows the buttons just fine using this code

DatePickerDialog(
            this,
            { view, year, month, dayOfMonth -> },
            year, month, day
        ).show()


on app open

but inside the PDFTron viewer it doesn’t show the buttons :frowning:


inside PDFTron viewer

Any thoughts would be greatly appreciated :slight_smile:

Hi Seth,

This issue is not specific to PDFTron, but rather android styling.
Could you try adding styling for the buttons to your alert dialog?
For example :

<style name="AlertDialogTheme" parent="ThemeOverlay.MaterialComponents.Dialog.Alert">
    <item name="buttonBarNegativeButtonStyle">@style/NegativeButtonStyle</item>
    <item name="buttonBarPositiveButtonStyle">@style/PositiveButtonStyle</item>
</style>

<style name="NegativeButtonStyle" parent="Widget.MaterialComponents.Button.TextButton.Dialog">
    <item name="android:textColor">#f00</item>
</style>

<style name="PositiveButtonStyle" parent="Widget.MaterialComponents.Button.TextButton.Dialog">
    <item name="android:textColor">#00f</item>
</style>

Then add that style to your AppTheme:
<item name="alertDialogTheme">@style/AlertDialogTheme</item>

Please see here for more information.

Best Regards,
Eamon

Good afternoon @emallon,

I tried what you recommended a couple weeks back and had no luck with it. I added that custom style back in right now and it still isn’t working.

<style name="AlertDialogTheme" parent="ThemeOverlay.MaterialComponents.Dialog.Alert">
        <item name="buttonBarNegativeButtonStyle">@style/NegativeButtonStyle</item>
        <item name="buttonBarPositiveButtonStyle">@style/PositiveButtonStyle</item>
    </style>

    <style name="NegativeButtonStyle" parent="Widget.MaterialComponents.Button.TextButton.Dialog">
        <item name="android:textColor">@color/colorPrimary</item>
    </style>

    <style name="PositiveButtonStyle" parent="Widget.MaterialComponents.Button.TextButton.Dialog">
        <item name="android:textColor">@color/colorPrimary</item>
    </style>

In the AppTheme:

<item name="alertDialogTheme">@style/AlertDialogTheme</item>

I’m confused if it’s an Android styling issue because the DatePickerDialog theming is working when I trigger it outside of the PDFTron context here.

Hi Seth,

Please add the following to your styles.xml

<style name="DatePickerTheme" parent="Theme.MaterialComponents.Light.Dialog.Alert">
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
    <item name="android:buttonBarNegativeButtonStyle">@style/DatePickerTheme.ButtonBarNegativeButtonStyle</item>
    <item name="android:buttonBarPositiveButtonStyle">@style/DatePickerTheme.PositiveButtonStyle</item>
</style>

<style name="DatePickerTheme.ButtonBarNegativeButtonStyle" parent="Widget.MaterialComponents.Button.TextButton.Dialog">
    <item name="android:textColor">@color/colorPrimary</item>
</style>

<style name="DatePickerTheme.PositiveButtonStyle" parent="Widget.MaterialComponents.Button.TextButton.Dialog">
    <item name="android:textColor">@color/colorPrimary</item>
</style>

Then add this to our PDFTronAppTheme

<item name="android:datePickerDialogTheme">@style/DatePickerTheme</item>

Please let us know if this resolves your issue

Best,
Eamon

1 Like

Hey @emallon!!

So this fixes the big issue of the primary and secondary button being invisible. They are now visible :raised_hands: Thank you for figuring out this solution :pray:

The “enter value” button is still invisible.

With the current state of things we are fine releasing how it is. Especially since the user can switch years/months using the picker. Definitely a “nice to have” to have the “enter value” button visible as well.

This is a great find!! Thank you for looking into this more fully! :slight_smile:

Hi Seth,

It looks like you are missing the neutral button style, please add this line to your DatePickerTheme

<item name="android:buttonBarNeutralButtonStyle">@style/DatePickerTheme.ButtonBarNeutralButtonStyle</item>

Create a style for your neutral button or you can reuse one of the styles from the other buttons.

<style name="DatePickerTheme.ButtonBarNeutralButtonStyle" parent="Widget.MaterialComponents.Button.TextButton.Dialog">
   <item name="android:textColor">@color/colorPrimary</item>
</style>

Best,
Eamon

1 Like

Got it! Thanks for your help with this

1 Like