I'm using SwitchPreferenceCompat
from androidx.preference:preference:1.2.0
. In Android Studio preview everything looks good:
But in real device it look this:
Here my preferences.xml
:
<PreferenceScreen xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:android="http://schemas.android.com/apk/res/android">
<PreferenceCategory app:title="@string/auth_header">
<SwitchPreferenceCompat
app:key="@string/auth_key"
app:title="@string/auth_title"
android:icon="@drawable/ic_fingerprint"/>
</PreferenceCategory>
</PreferenceScreen>
And app theme:
<resources xmlns:tools="http://schemas.android.com/tools">
<!-- Base application theme. -->
<style name="Theme.Notes" parent="Theme.Material3.DayNight.NoActionBar">
<!-- Primary brand color. -->
<item name="colorPrimary">@color/color_primary</item>
<item name="colorPrimaryVariant">@color/color_primary_variant</item>
<item name="colorOnPrimary">@color/white</item>
<!-- Secondary brand color. -->
<item name="colorSecondary">@color/color_secondary</item>
<item name="colorSecondaryVariant">@color/color_secondary_variant</item>
<item name="colorOnSecondary">@color/black</item>
<!-- Status bar color. -->
<item name="android:statusBarColor">@android:color/transparent</item>
<!-- Customize your theme here. -->
<item name="android:windowLightStatusBar">true</item>
<item name="windowActionModeOverlay">true</item>
<item name="colorAccent">@color/black</item>
</style>
</resources>
Note that colorAccent
is not related to this problem. Without it the result is the same (even if you remove all values from the theme, the result will not change). I use it just to set the preference header color.
Question: Is this a library bug or am I doing something wrong?
Device: POCO X3 NFC (MIUI 12.5, Android 11).
androidx.preference:preference:1.2.0
com.google.android.material:material:1.8.0