Forum Xamarin Xamarin.Forms

From a Cross platform code, how can I change the default color of the android app?

Greg79Greg79 FRMember ✭✭

The DatePicker for instance is displaying a color that I cannot change by the datepicket attributes in the Xamarin forms. I suppose I can play with styles in Android but I cannot find the way. Does somebody can help me?

Thank you.


  • NMackayNMackay GBInsider, University mod


    I suspect you'll need to implement a customer renderer.

    Also worth checking out effects but the renderer discused above should help you.

  • Greg79Greg79 FRMember ✭✭

    Thank you for your feedback but not sufficient. It is my fault, I was not clear. My issue is on the Popup opened by the Date Picker. This popup has not the same color than my app and I want to change it. I push the idea a little on the renderer but it seems that it is not enough.

    Did you face this kind of problem?

    Thank you

  • Greg79Greg79 FRMember ✭✭

    Here you can find a screen shot of the popup I want to change this blue color

  • AdamMeaneyAdamMeaney USMember ✭✭✭✭✭

    You don't change it from Cross Platform code.

    The thing I would do is probably a style in the Android Styles.xml file for it.

  • Greg79Greg79 FRMember ✭✭
    edited January 2017

    I tried without success but maybe I did it badly. For me this is the best way to proceed but if other solution could resolve, I take it.

    I change the style.xml by adding this line
    <item name="android:calendarTextColor">#224064</item>

    If there is another way to set this property through the renderer I take it.

    Thank you.

  • NMackayNMackay GBInsider, University mod

    Ahhh, okay.

    As adam correctly stated, you'd have to modify your android theme, for UWP you'd have to override the style in the platform specific App.xaml file, in iOS....I'm guessing it'll be pretty tricky. Might be a combination of renderer + style.

    To style the dialog correctly I had to implement my own platform specific dialog service.

    3rd party providers like Telerik provide customizable pickers for dates.

  • Greg79Greg79 FRMember ✭✭

    What do you mean by build your own Platform specific dialog service?

    Did you re-create all the popup?

  • NMackayNMackay GBInsider, University mod
    edited January 2017

    Well Xamarin Forms just calls the platform specific API's wrapped up by Xamarin with it's dialog implementation, you can download the source from github and take a look.

    You can then use the dependency service to access your own native implementation of the dialog.

    In Xamarin 2.3.4 you can also surface native controls and bind to them so that's potentially another avenue to investigate.

Sign In or Register to comment.