is there any way to change the "Default Color" for Controls in Xamarin Forms (particularly in Android)? The Controls, which you see in the Pictures all use the same color, and because of that i think there is something like a default resource. I have seen that you can change the colors manually, but i don't want to make a template for the picker, and each other control that hasn't a property built in for this color.
ListView:
The Underline of the Picker when clicked:
and The Window which opens when the Picker is clicked:
Can i somehow change this default color?
You need to check your styles in android.
Droid Project-> Resourse folder -> Values folder -> styles.xml
There is colorPrimary and colorAccent. So you need to change it to your color
You can customize your app with styles.xml. For mode details look at android styles and themes.
Edit:
Also if you click on the 3 dots on background in Attributes, you can edit and add color resources.
See example picture
Change the colorPrimary and colorAccent of your AppTheme in Styles.xml
There are a few attributes you can change in your AppTheme that you use which you declared in your styles.xml
There are a few like colorPrimary, colorPrimaryDark, colorAccent, colorControlNormal, etc.
I found this cheat sheet in the past, which might be outdated but might come in handy for you: Android Color Control Cheat Sheet.
Related
I will try to explain in detail‚ please help. I opened a new project‚ in the new project the "theme" section was opened twice‚ one light one dark. I added black text to the app ‚the text looked white because my phone is a dark theme. This is very good but incomprehensible. I only have one color.xml file (not for the night version) How did the text change to white? This is fine but the icon (vector ‚xml) I added and gave it a gray color ‚but now it was incomprehensible. The color of the icon changed from gray to black in the dark. I wanted him to change to white. I also opened for Colors.xml for the night. Now that I think there will be no mistakes, nothing has changed. The night is getting black in them.
How can I make an icon (vector ‚xml) gray in light and white in the dark theme?
I have a dark and light "theme" file ‚Do I have to separate the "colors" into dark and light themes?
I hope I was able to explain ‚Thank you so much!
The text's color has changed to white because you didn't set a color, and it's inherits from the default android settings.
If you want to change (customise) the colors depending on the theme, I suggest you to override the colors.xml file for the night mode.
Declare the color that you want for your icon.
colors.xml
<color name="iconColor">#FF808080</color>
colors.xml (night)
<color name="iconColor">#FFFFFFF</color>
In your drawable, you must set this new color.
android:fillColor="#color/iconColor"
It's also a good thing to override the others colors (primary, primaryLight, etc.) to lighter variants.
You can practice here if you want to exercise the theme changed on android (this is in Kotlin, but the same course exists in Java).
I made the color changes in this component Entry, but it was missing this standard pink component. I would like to know his name so you can change its color too.
Resources> styles #000000
change color according to your requirements.
You could add the below codes in your activity theme of Resources/styles
<item name="android:colorControlActivated">#ff0000</item> //set the color you want
I am trying out with Dark Mode Theme Support for Android 10 for my App.
I am able to work with all other things in Dark Mode except App Launcher Icon.
For reference, I was using below link
https://developer.android.com/guide/topics/ui/look-and-feel/darktheme
I know there is no such mention of App Icon change as per Day/Night theme changes.
Just for confirmation, need all your inputs on will it be possible to change the app icon as per change in theme from normal to dark and vice versa.
Thanks in advance.
Have you checked the Themes and styles section in documentation?
Your themes and styles should avoid hard-coded colors or icons
intended for use under a light theme. You should use theme attributes
(preferred) or night-qualified resources instead.
Here are the two most important theme attributes to know about:
?android:attr/textColorPrimary This is a general purpose text color. It is near-black in Light theme and near-white on Dark themes. It contains a disabled state.
?attr/colorControlNormal A general-purpose icon color. It contains a disabled state.
So the ?android:attr/textColorPrimary and ?attr/colorControlNormal will change based on the theme (black -> white & white -> black). I'm assuming we can set those colors as android:tint property to achieve the dark/white theme for vector icons. The con is your icons need to be black and white only.
To achieve Dark Mode for Icons in Android:
Create the separate resource folder named values-night
Inside values-night folder define your night theme (ex. theme.xml)
Define all the desired colours you want in Dark mode inside theme.xml
Now, inside your icon drawable define the icon tint attribute as follows-
<vector android:height="24dp" android:tint="?attr/colorPrimaryDark" android:viewportHeight="24" android:viewportWidth="24" android:width="24dp"
Using the above code, the icon colour will change based on colours defined in Dark and Light mode theme in your project
Pictures:
res folder values-night
define your Dark mode theme
change icon tint attribute of your Icons
light mode
Dark mode
No, the app icon does not support dark mode.
Apart from the app icon, other images colour can be modified :
Try using
android:drawableTint="#color/black"
OR
app:tint="#color/black"
[
Add xml import by presing ALT+Enter or use following:
xmlns:app="http://schemas.android.com/apk/res-auto"
]
with your desired image.
UPDATE:
or Just use:
ivMyImageView.setColorFilter(ActivityCompat.getColor(context, android.R.color.holo_green_light))
PS:
(Attribute drawableTint is only used in API level 23 and higher)
I think it possible, just launcher doesn't support display it.
BTW, I created new color resource into values-night and values, eg:
<!-- values-night/colors.xml -->
<color name="icon_background">#000000</color>
<!-- values/colors.xml -->
<color name="icon_background">#FFFFFF</color>
Then set background color into app icon:
<!-- mipmap/ic_launcher.xml -->
...
<background android:drawable="#color/icon_background" />
...
<!-- mipmap/ic_launcher_round.xml -->
...
<background android:drawable="#color/icon_background" />
...
App's icon now change when toggle dark mode..., but only for app swicher (icon display on top of window), but lancher does't update...
I've tested on Android 11 on Pixel 4XL phone (using Google Launcher).
Anyone else?
Dark mode is not supported for app icons (launcher icons).
Reason for this:
Some resource qualifiers like locale/density/version code do not
change in day-to-day use and changing icons on those are supported.
But we do not recommend changing app icons and labels based on
frequently changing parameters and it is not supported at most places
in system UI. Users create a memory map between apps and their
corresponding icons/labels. Changing these frequently is disruptive to
the user.
There is an issue filed with google for this and the decision is:
Won't Fix (Intended Behavior)
Issue tracker: https://issuetracker.google.com/issues/147521650?pli=1
Well, you can use ure resource colors. Add night mode variation (right click values, New -> Values resource file, set file name "colors" and qualifier "Night mode". You can do variation of drawable specifically if you want.
The main drawback - it doesn't really stable. I don't know if it's just me, but I'm getting weird behaviour in emulator (sorry, can't test on device right now). Right after install icon is set with correct mode, but when you change to other it doesn't get updated. When you try to move icon it using current theme variation however.
Try to add mipmap-anydpi-v26 & mipmap-night-anydpi-v26 icons in your source code. I tried to add but is a little bit buggy. I theory icons support dark theme XD
Here is an example
I know this question must be asked before, but I don't know where can I find the solution since I don't know what is the name.
I want to change the color to red. How can I do to achieve this ?
Thanks a lot !
A style on Android contains a number of different attributes. This can control background color, text color, font styling, etc.
The Theme.AppCompat.Light.DarkActionBar style contains several attributes for an overall light theme with a dark colored action bar.
If the background color you want to use needs white text and icons on top of it, you reference this as the parent and just change the background color.
<item name="android:background">#ff0000</item>
If your background color would look better with black (or dark) text, you could set the parent to Theme.AppCompat.Light.
If you want to change the color of the application bar (and the application's primary color – the application bar inherits it), just change your colorPrimary attribute. Like this:
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="colorPrimary">#color/yourColorResource</item>
</style>
Instead of #color/yourColorResource, you can directly use a color's hexcode or Android's pre-defined resources such as #android:color/holo_red_dark
For the status bar's color, you can use similarly use the colorPrimaryDark attribute. You can read more about this here.
I am using a picker on my application of type time picker. The picker works fine on iOS devices, however when I go to the android application, it appears, but the font color is white, and cant see the numbers.
I do not want to change the background to a darker color because it doesnt match the rest of the application and wont be matching the ios app. I was wondering if there is a way to change just the font to black or gray color.
I have already tried some of the solutions posted, and changing the themes, but it has not worked out for me.
You need to create custom theme
<resources>
<style name="Theme.NoActionBar" parent="#style/Theme.AppCompat.Light"> </style>
</resources>
Put this code in /platform/android/res/values/custom_theme.xml
To fix the solution to this, you can add the following in your Theme.xml file under platform/android/values.
You can visit this link for my post on the appcelerator developer forum where I had raised this issue.
http://developer.appcelerator.com/question/182115/picker-font-color-on-android
Now you can apply the theme attribute to the window that you are planning on using your picker in, and applying the Light or LightDarkBar theme. This will turn the color your picker font to black.
You can format the code in the editor after pasting it. You can do that by pressing command shift F on mac, and for windows I am sure its control shift F, but not 100% on that.