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
Related
I am a student trying to learn app development with android studio. For my first project, im just building a basic calculator app. I have stumbled across a problem that I couldnt solve and didnt find a helpfull post about. It occurs when I trun on dark mode on the virtual device. Here are 2 pictures showing what happens.
How it looks with dark mode
How it is supposed to look
My activity_main.xml consists of some buttons that all have the same style and a TextView.
I left all the other files untouched. Id love some advice on how to fix this. Thanks for reading!
You are most likely using the following default DayNight theme in your themes.xml file (values/themes/themes.xml)
<style name="Theme.MyApp" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
If you don't want things to change in night mode, you can change that to use the Light theme instead
<style name="Theme.MyApp" parent="Theme.MaterialComponents.Light.DarkActionBar">
and delete the themes.xml (night) file if it exists. There is some extra info about these options here
there are two themes : night and not night check in IDE Design tab you can view how it looks in both click the circle in pane where design is displaying it displays Not Night and Night whatever theme you are using it will affect because of these two modes, by default IDE shows not night
To show screen same in both modes you need to change some settings like in your activity_main.xml at root layout change background to #color/white and see what happens it should be sorted out since your button colors are dark ...the text Placeholder color needs to be changed accordingly
<LinearLayout
background=#color/white
other layout etc to follow
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).
Suppose I have my own two custom defined themes in the styles.xml, one for Dark and one for Light. When a user goes into their smartphones settings and change to dark mode, how do I have my application use my own custom dark theme? Same with my Light theme.
In general, I suppose my question is more like how do I control what color my application uses when a user changes between light and dark mode. I do not want to use the default colors that come in each mode.
You can override the colors that you use in your layout and put them in values-night/colors.xml. So, in light theme values/colors.xml will be used and in the night theme, values-night/colors.xml will be used.
Let's say you have a color assigned to a button, you write following line, make sure the color name is same:
values/colors.xml
<color name="colorButton">#6d85c9</color>
values-night/colors.xml
<color name="colorButton">#color/colorWhite</color>
And then you can assign the color to the button you do normally.
Let me know if you have more questions.
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.
I'm trying to implement Material Theme with SDK 4.0.0. Here are some issues I have:
9 patch splash (background.9.png) isn't displayed correctly. Worked fine before (logo centered with all white background, no black spots).
here is my custom theme:
<style name="MyMaterial" parent="#style/Theme.AppCompat.Light.DarkActionBar">
<item name="colorPrimary">#4CAF50</item>
<item name="colorPrimaryDark">#388E3C</item>
</style>
There are some windows opened dynamically that I want to have different colorPrimary/colorPrimaryDark than the defaults above. Is it possible?
My app uses a tab group. There is a underline underneath an active tab. I want to change the underline's color to #ffffff without affecting other controls' active color. Unfortunately colorAccent affects all controls' color. What should I do?
Can I remove the default tab divider and add shadow underneath so that the tabs look like the Google Play Store app's?
My app uses push notification. I usually specify my appicon.png for the notification's icon. Now upgraded to SDK 4.0.0 with Material Theme, the appicon shown in the notification becomes all white. Can I show the regular appicon instead?
Since Android 5.0, you need to provide the until then optional padding box for nine-patch images. The newest version of the TiCons CLI generates this for you: http://npmjs.com/package/ticons. You need black pixels on the bottom and right side of the image, except for the bottom left + right and top right pixel.
You can define multiple themes and then use the theme property in createWindow() to select one.
Android's new Material Design Theme has limited options in what you can style. See https://developer.android.com/training/material/theme.html
See previous
Not sure about this one but did you check http://docs.appcelerator.com/platform/latest/#!/guide/Sending_and_Scheduling_Push_Notifications-section-43298780_SendingandSchedulingPushNotifications-icon?