Search code examples
androidkotlinandroid-preferencespreferencesedittextpreference

Why is my positive and negative button text in EditTextPreference not showing up?


So I have a preference screen that has an edittextpreference. I've also set the text of the positive button and negative button of it in the XML file as follows:

    <EditTextPreference
    android:key="@string/key_username"
    android:selectAllOnFocus="true"
    android:singleLine="true"
    android:summary="@string/nothing"
    android:title="@string/username"
    android:iconSpaceReserved="true"
    android:icon="@drawable/profile"
    android:positiveButtonText="@string/positive_button"
    android:negativeButtonText="@string/cancel" />

However, what shows up when I run the app is like this

enter image description here

I'm not sure its because the color is white or its just not showing up. How can I fix this?


Solution

  • I had the same issue and fixed it by changing my theme to material components in styles.xml. It does change the text, dark mode background colour and other aspects of the app though.

    <style name="AppTheme" parent="Theme.MaterialComponents.DayNight.NoActionBar">
            <item name="colorPrimary">@color/colorPrimary</item>
            <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
            <item name="colorAccent">@color/colorAccent</item>
        </style>