Android Question Switch, Checkbox, DatePicker COLOR

Mike1970

Well-Known Member
Licensed User
Longtime User
Hi, how can i change the color of this elements?

WhatsApp Image 2019-05-30 at 09.23.07.jpeg WhatsApp Image 2019-05-30 at 09.23.08.jpeg

I think i have to do it in the manifest, but i have to keep the appcompat theme.

Thanks
 

Mike1970

Well-Known Member
Licensed User
Longtime User


to change the checkbox and switch color i used:

B4X:
SetApplicationAttribute(android:theme, "@style/MyAppTheme")
CreateResource(values, colors.xml,
<resources>
   <color name="actionbar">#FFB30037</color>
   <color name="statusbar">#FFFFD2DE</color>
   <color name="textColorPrimary">#ffffffff</color>
   <color name="navigationBar">#FFB30037</color>
</resources>
)
CreateResource(values, theme.xml,
<resources>
    <style name="MyAppTheme" parent="Theme.AppCompat.Light">
       <item name="colorPrimary">#FFFF0000</item>
       <item name="android:buttonTint">#FF876DFF</item>
       <item name="colorControlActivated">#FF876DFF</item>
    </style>
</resources>
)

And added this two lines:

B4X:
<item name="android:buttonTint">#FF876DFF</item>
       <item name="colorControlActivated">#FF876DFF</item>

But i don't know how to change the color for the MaterialDateTImePIcker..
I saw that there is the method: "ColoAccent2" to set the color, but it accept only string, not int.. what i have to write? hex code?

Edit:
To color the MaterialDateTimePicker, you have to use the method "ColorAccent2", and the string you have to put is the color hex (# way, not 0x) code without alpha level

Ex: DTP.ColorAccent2 = "#56a1d3"
 
Last edited:
Upvote 0
Top