As the title says, I want to change the color of DatePicker from black to white but I did not sorted this out after trying multiple times. I've seen Nativescript's documentation regarding this but I might not understand it correctly how to do it. Also tried this example for Android API21+ from https://docs.nativescript.org/ui/components/date-picker , but nothing happens:
<!-- DatePicker in calendar mode -->
<style name="AppTheme" parent="AppThemeBase">
<item name="android:datePickerStyle">#style/CalendarDatePicker</item>
</style>
<style name="CalendarDatePicker" parent="android:Widget.Material.Light.DatePicker">
<item name="android:datePickerMode">calendar</item>
<item name="colorPrimary">#color/ns_blue</item>
<item name="colorPrimaryDark">#color/ns_primaryDark</item>
<item name="colorAccent">#color/ns_accent</item>
</style>
You need to add it them into colors.xml:
App_Resources/Android/src/main/res/values-v21/colors.xml
<color name="ns_blue">#ff7800</color>
<color name="ns_primaryDark">#17143d</color>
<color name="ns_accent">#8095ac</color>
according to this solution:
Nativescript Datepicker change text color
Related
As title, I need to change my app start up background color. Actually, is full white, and need to be #202030
I tried with
<item name="android:windowBackgroundColor">#202030</item>
in my style.xml but it's full black, no matters what color I set to this attribute.
Also, I can't use directly
<item name="android:backgroundColor>#202030</item>
because I will get also Cut/Copy/Paste background menu with this color and text in black
This is my style:
<style name="AppTheme" parent="Theme.AppCompat">
<!-- Customize your theme here. -->
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="android:windowBackground">#202030</item>
<item name="colorAccent">#1E88E5</item>
<item name="android:navigationBarColor">#202030</item>
<item name="android:statusBarColor">#1d1d30</item>
<item name="android:textColorPrimary">#E0E0E0</item>
<item name="android:timePickerStyle">#style/TimePickerStyleLight</item>
<item name="android:fontFamily">#font/product_sans_regular</item>
<item name="android:textColor">#E0E0E0</item>
<item name="android:colorControlHighlight">#3399ff</item>
<item name="android:colorControlActivated">#3399ff</item>
<item name="alertDialogStyle">#style/AppCompatAlertDialogStyle</item>
<item name="android:textColorHint">#BDBDBD</item>
</style>
In your colors.xml
add
<color name="splash_color">#202030</color>
then in style.xml add splash_color to your theme.
<item name="android:windowBackground">#color/splash_color</item>
to create your custom color in Android Studio, you can add you color in past Values->Color->then put you line color that you want.
step-one
Then, you can go in you xml background color and add in your layout, just as simple
step-two
i hope that i can help, if this is not your aswer, comment here and explain more what you want.
I have a menu in my android activity (I am working with Xamarin.Android) and that contains several items, like this one:
<item android:id="#+id/menuitem1"
android:icon="#drawable/ic_action_share"
android:showAsAction="ifRoom" />
I can customize the whole ActionBar. But I want to customize just one item in the actionbar. Like the following Icon in the middle (the blue one):
How can I achive this? Thanks in advance.
First thing that we need to do is set up the basic colour values in res/values/colors.xml that we used in Jeff’s Generator tool:
<color name="sa_green">#14a804</color>
<color name="stacked_green">#118504</color>
<color name="accent_green">#97e08f</color>
create a new style, which we’ll call “ActionBar” in res/values/styles.xml:
<style name="ActionBar" parent="#android:style/Widget.Holo.Light.ActionBar.Solid.Inverse">
<item name="android:background">#color/sa_green</item>
<item name="android:backgroundStacked">#color/stacked_green</item>
<item name="android:backgroundSplit">#color/sa_green</item>
</style>
Now it must set this style on the ActionBar by adding an actionBarStyle to the theme in res/values/styles.xml:
<style name="AppTheme" parent="android:Theme.Holo.Light.DarkActionBar">
<item name="android:actionBarStyle">#style/ActionBar</item>
</style>
.
.
.
try this ...
I have a Android 5 device and I set up some Material Styles using this blog:Material Design Theming for Xamarin.Forms Android Apps and got this theme:
Values-v21\styles.xml
<resources>
<style name="MyTheme" parent="#android:style/Theme.Material.Light.DarkActionBar">
<item name="android:colorPrimary">#color/color_primary</item>
<item name="android:colorPrimaryDark">#color/color_primary_dark</item>
<item name="android:colorAccent">#color/accent</item>
<item name="android:colorControlNormal">#color/color_primary</item>
<item name="android:colorControlActivated">#color/color_primary</item>
<item name="android:colorControlHighlight">#color/color_primary</item>
<item name="android:windowContentTransitions">true</item>
<item name="android:windowAllowEnterTransitionOverlap">true</item>
<item name="android:windowAllowReturnTransitionOverlap">true</item>
<item name="android:windowSharedElementEnterTransition">#android:transition/move</item>
<item name="android:windowSharedElementExitTransition">#android:transition/move</item>
<item name="android:actionBarStyle">#style/MyTheme.ActionBarStyle</item>
</style>
</resources>
Values\colors.xml
<resources>
<color name="color_primary">#404040</color>
<color name="color_primary_dark">#404040</color>
<color name="accent">#379ADE</color>
</resources>
This works fine.. BUT.. I cant seem to work out why my selected item is appearing orange?
How do I change the color of my selected item using Styles.. Where is the Orange coming from?
Ps. if I remove the Styles it returns to the default blue.
I also found Android Color Control Cheat Sheet but can't see an entry to change listview selected item
It looks like you're having Xamarin.Forms Styles and Android resources mixed up.
In Xamarin.Forms you can change the color based on a property change like this:
<ResourceDictionary>
<Style TargetType="Entry">
<Style.Triggers>
<Trigger TargetType="Entry" Property="IsFocused" Value="True">
<Setter Property="BackgroundColor" Value="Yellow" />
</Trigger>
</Style.Triggers>
</Style>
</ResourceDictionary>
You may want to define your colors Xamarin.Forms <ResourceDictionary> (not Android <resource>) and maybe populate the dictionary on startup time from platform-specific resources.
A general side note: when using Xamarin.Forms really focus on your app's functionality in a platform-independent manner; from experience I can say it's difficult and messy to retroactively make the app platform-independent when you've taken subtle dependencies on the platform, such as colors, sizes, UI paradigms etc.
I'm using a custom theme that inherits from DarkActionBar and I want to customize dropdown menu to be white like when using Light Holo theme.
I've been able to change the background to white using:
<style name="MyTheme" parent="#style/Theme.Light.DarkActionBar">
<item name="android:actionDropDownStyle">#style/MyDropDownNav</item>
</style>
<style name="MyDropDownNav">
<item name="android:background">#drawable/spinner_background_white</item>
<item name="android:popupBackground">#drawable/menu_dropdown_panel_whyite</item>
<item name="android:dropDownSelector">#drawable/selectable_background_white</item>
</style>
But I haven't any clue of how to change the text color to black. Because after setting white drawable the problem is that text isn't visible because is white on white background.
I answer myself after some investigation.
In addition to question's styling you need to:
Customize android:spinnerDropDownItemStyle for actionBarWidgetTheme changing it's text appearance.
Also don't forget that dropdown list is managed by the adapter you use. Then if you used the standard one (simple_dropdown_item_1line) there's no problem. But if you used a custom one like me (to be able to add an icon) don't forget to apply style="?attr/spinnerDropDownItemStyle" in your layout TextView.
Then final custom style is:
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<style name="Theme.myapp" parent="#style/Theme.Light.DarkActionBar">
<item name="android:actionDropDownStyle">#style/myapp_DropDownNav</item>
<item name="android:actionBarWidgetTheme">#style/myapp.actionBarWidgetTheme</item>
</style>
<style name="myapp.actionBarWidgetTheme" parent="#style/Theme.">
<item name="android:spinnerDropDownItemStyle">#style/myapp.Widget.DropDownItem.Spinner</item>
</style>
<style name="myapp_DropDownNav" parent="#style/Widget.Spinner.DropDown.ActionBar">
<item name="background">#drawable/spinner_background_ab_myapp</item>
<item name="android:background">#drawable/spinner_background_ab_myapp</item>
<item name="android:popupBackground">#drawable/menu_dropdown_panel_myapp</item>
<item name="android:dropDownSelector">#drawable/selectable_background_myapp</item>
</style>
<style name="myapp.Widget.DropDownItem.Spinner" parent="Widget.DropDownItem.Spinner">
<item name="android:textAppearance">#style/myapp.TextAppearance.Widget.DropDownItem</item>
</style>
<style name="myapp.TextAppearance.Widget.DropDownItem" parent="TextAppearance.Widget.DropDownItem">
<item name="android:textColor">#color/black</item>
</style>
Where drawables in myapp_DropDownNav are white background ones that you can generate with ActionBar Style generator in Android Asset Studio
Try setting itemTextAppearance. That should achieve what you want.
I have stumbled on what may be the simplest way to do this. I was working with the AppCompat library.
<style name="ApplicationTheme" parent="#style/Theme.AppCompat">
<item name="android:actionBarWidgetTheme">#style/Theme.AppCompat.Light</item>
<item name="actionBarWidgetTheme">#style/Theme.AppCompat.Light</item>
</style>
My advice is to simply inherit from the Sherlock.Light theme and change the applicable fields to the Dark values. For my app, we wanted a white "up" icon, and white text for the action labels. I don't provide dark versions of my actionbar icons, so they are all white anyway. So after several hours messing around with it and following different people's suggestions, I finally found what I was looking for in the ABS themes file.
I inherit from Sherlock.Light (well, technically HoloEverywhereLight.Sherlock but...) and change:
<item name="android:actionMenuTextColor">#color/White</item>
<item name="actionMenuTextColor">#color/White</item>
<item name="android:homeAsUpIndicator">#drawable/abs__ic_ab_back_holo_dark</item>
<item name="homeAsUpIndicator">#drawable/abs__ic_ab_back_holo_dark</item>
<item name="android:dividerVertical">#drawable/abs__list_divider_holo_dark</item>
<item name="dividerVertical">#drawable/abs__list_divider_holo_dark</item>
That's it. It's way simpler and easier than trying to extend classes, restyle things in code, etc.
There is no Theme.Light.Dialog to use with the rest of my project that is using Theme.Light.
How can I change Theme.Dialog to look like a Theme.Light version of Dialog.
I know that I must overwrite sections of Theme.Dialog in styles.xml as below. What items should I overwrite with which values?
<style name="dialog_light" parent="#android:style/Theme.Dialog">
<item name="android:???????"></item>
<item name="android:???????"></item>
</style>
I could just make the background that light white grey, but the buttons, spinners etc are also different on the light theme to look better on the light background.
EDIT
Looks like I got it working.
<color name="black">#FF000000</color>
<color name="whitegrey">#FFF2F2F2</color>
<style name="dialog_light" parent="#android:style/Theme.Dialog">
<item name="#android:windowBackground">#color/whitegrey</item>
<item name="#android:textColor">#color/black</item>
</style>
Looks like I got it working.
<color name="black">#FF000000</color>
<color name="whitegrey">#FFF2F2F2</color>
<style name="dialog_light" parent="#android:style/Theme.Dialog">
<item name="#android:windowBackground">#color/whitegrey</item>
<item name="#android:textColor">#color/black</item>
</style>
Further to the above, to avoid making up colors, I did this:
<!-- Makes a "light" equivalent of Theme.Dialog -->
<style name="dialog_light" parent="#android:style/Theme.Dialog">
<item name="#android:background">#android:color/background_light</item>
<item name="#android:textColor">#android:color/primary_text_light</item>
</style>
This is good, thanks!
I just changed it a bit: when I run what you suggested, the entire screen is painted with the back color and the dialog does not look as it should (with the previous activity dimmed).
So instead of using
#android:windowBackground
just use
#android:background