I'm trying to change the datepicker color to white in Android. I've tried with colorPrimary in styles.xml with no luck:
<style name="AppTheme" parent="AppThemeBase">
<item name="android:datePickerStyle">#style/SpinnerDatePicker</item>
</style>
<style name="SpinnerDatePicker" parent="android:Widget.Material.Light.DatePicker">
<item name="colorPrimary">#FFF</item>
<item name="android:datePickerMode">spinner</item>
</style>
Also, is there a way to use one color in a component and another in a second or am I bound to use one color for the whole app?
You can't change the color of the DatePicker dynamically... at least it is not a trivial job. The thing is that even in native Android changing the color via code-behind can be achieved only with the Reflection API (see here for details).
To change the text color of the DatePicker there is one important thing to notice - you should apply android:textColorPrimary directly in the main app theme (see the comments here for details)
For example:
values-v21/style.xml
<style name="AppTheme" parent="AppThemeBase">
<item name="android:textColorPrimary">#color/ns_green</item> <!-- HERE -->
<item name="android:datePickerStyle">#style/SpinnerDatePicker</item>
<item name="android:timePickerStyle">#style/SpinnerTimePicker</item>
</style>
In the example above ns_green is defined in colors.xml
<color name="ns_green">#1eb234</color>
Related
How can I change the color of the text circled in the below screenshot?
I played around with the style.xml but have not yet found any property that impacts this parts.
Add the following code into style.xml in android project.
Create a new style which defines the color on Timepicker.
<style name="Theme.picker" parent="Theme.AppCompat.Light.Dialog">
//background color
<item name="android:background">#13216a</item>
//Title background color
<item name="colorAccent">#f8a519</item>
//text color
<item name="android:textColor">#FF0000</item>
//number text color
<item name="android:textColorPrimary">#FF66FF</item>
</style>
Apply the style in MainTheme .
<item name="android:timePickerDialogTheme">#style/Theme.picker</item>
Screen shot
Notice: This is a simple solution, and it will also change the button text color, if you want to separate them, you will need a custom renderer.
Currently the under line color is White, how would I change the color.
I've looked at this solution using style which I really like, but which property do I need to set to update this under line color?
Xamarin Android - Change colors for TimePicker keyboard view
In general, a property in style may affect the appearance of more than one control.
For example in your issue,you could try to define in your style to change the underline color like:
<style name="Theme.picker" parent="Theme.AppCompat.Light.Dialog">
<item name="colorControlNormal">#ff00ff</item> // the underline normal color which no focus
<item name="colorControlActivated">#ff0000</item>// the underline activate color which focus
</style>
According to another StackOverflow question it's possible to remove the margin of a normal Button via styles.xml.
I would like to do the same for the margin/padding of Entry. Given that my trivial assumption would be that it uses an EditText beneath I tried:
<style name="MainTheme.Base" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="editTextStyle">#style/MyEditText</item>
</style>
<style name="MyEditText" parent="Widget.AppCompat.EditText">
<item name="android:layout_margin">0dip</item>
</style>
Unfortunately, this doesn't have any effect. Even when I use 50dip as a value there's no effect. What are the correct setting in styles.xml to affect the Entry-widgit?
In your MainTheme.Base
<item name="android:editTextStyle">#style/EditTextStyle</item>
And your #style/EditTextStyle
<style name="EditTextStyle" parent="#android:style/Widget.EditText">
<item name="android:layout_margin">0dip</item>
<item name="android:padding">0dip</item>
</style>
Note: This going to depend upon your layout, as the "margins" are to parent Android layout containers (ViewGroup) and thus your Forms' Entry might not be effected. If you are not sure that you have set this up correctly, throw a color into the style to double check, something like all Entries having Green text:
<item name="android:textColor">#00f000</item>
When displaying datepicker in XAML page bottom borderline color is black. I want to change this color to white. How to solve this problem. Is there any custom renderer to set the bottom borderline color. I am using absolute layout in my XAML page. By default when displaying datepicker on my page the date with black bottom borderline color. I just want to change to white color.
I posted an answer yesterday for another user who wanted to change the bottom line color of a text view. You can most likely do it the same way with a custom DatePicker; simply change the background to the xml resource in your custom renderer.
See here:
How can i change editor bottom border line color using custom renderer in xamarin forms
Just change the color values in the XML code to color="white".
You have to create an XML file in drawable folder and add this styling. You can customize it according to the color you want.
Add this file to style of datepicker, Resource.Style.datepicker.
<style name="datepicker" parent="Theme.AppCompat.Light.Dialog">
<item name="colorPrimary">#color/clrDatePrimary</item>
<item name="colorPrimaryDark">#color/clrDatePrimaryDark</item>
<item name="colorAccent">#color/clrDateAccent</item>
</style>
My app's main screen is rendered via SKCanvasView. The colors accurately reflect the values I specified in code.
If I swap-in SKGLView (hardware-accelerated version), changing no other code, the result is 60% darker:
<!--<skia:SKCanvasView PaintSurface="OnCanvasViewPaintSurface" />-->
<skia:SKGLView PaintSurface="OnCanvasViewPaintSurface" />
Why is this happening and how do I fix it?
The answer can be found here: https://github.com/mono/SkiaSharp/issues/299#issuecomment-331990904
I found the solution to the problem. There is a specific attribute that is set in the splash screen style, but is not unset (for some reason) when the style is changed.
In the splashscreen style, note this:
<item name="android:backgroundDimEnabled">true</item>
Docs: https://developer.xamarin.com/api/field/Android.Resource+Attribute.BackgroundDimEnabled
This is not unset when the style is switched. So, to fix this, just set it to false:
<item name="android:backgroundDimEnabled">false</item>
Here is a repository that demonstrates this: https://github.com/mattleibow/AndroidGLSurfaceViewTests