问题
I was searching for a way to change the colors of the ok and cancel button of my custom picker. I added this code to the styles file on the android project:
<style name="SpinnerDialog" parent="Theme.AppCompat.Light.Dialog">
<item name="android:popupBackground">#039BE5</item>
<item name="colorPrimary">#039BE5</item>
<item name="colorPrimaryDark">#039BE5</item>
<item name="colorAccent">#039BE5</item>
</style>
I run the app on my Xiaomi POCOPHONE F1 (Android v9) and on 2 emulators (Android v8.1) the color changed and everything worked fine, I tried deploying the app on my tablets (Android v5.1) the colors didn't change!!
Am I missing something?
回答1:
if you want to use style for the dialog ,you could try this:
in your theme style:
<item name="android:alertDialogTheme">@style/SpinnerDialog</item>
then custom dialog style:
<style name="SpinnerDialog"
parent="android:Theme.Material.Light.Dialog.Alert">
<item name="android:colorAccent">#039BE5</item>
回答2:
What are the settings of your android version / SDK. Maybe you have set a too high version, so the app doesn't work on devices that have a lower android version than your own pocophone.
You can change the settings under your Android project properties -> Application, set the Target Android Version and Compile using Android Version to API Level (of your tablet) to fix it.
来源:https://stackoverflow.com/questions/56540894/picker-buttons-color-not-changing-on-android-5-1