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?
Related
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 want to change the action bar color and text color as in Instagram. Because when I make a gray color, the icon and the time are not clear.
try using this code,
<style name="statusBarStyle" parent="#android:style/Theme.DeviceDefault.Light">
<item name="android:statusBarColor">#color/status_bar_color</item>
<item name="android:windowLightStatusBar">false</item>
its not my code and i got this from here.
According to the guidelines, Starting with Android 5.0 all Notification icons must be entirely white.
The only way to have a colored icon is to lower your targetSdkVersion to values <21, but I think you would do better to follow the guidelines and use white icons only.
If you still however decide you want colored icons, you could use the DrawableCompat.setTint method from the new v4 support library.
I am using the Leanback library for an Android TV application, and I am using the typical BrowseFragment that uses ImageCardViews for navigation. The ImageCardViews show a ripple effect when clicked: a semi-opaque white circle starts in the middle and grows to fill the View.
I am trying to change the ripple color to match my app's primary color. My application uses a custom Theme that inherits from Theme.Leanback, and I thought (based on e.g. https://stackoverflow.com/a/31922339/925478) that I could change the ripple color by overriding the colorControlHighlight attribute in the theme:
<style name="MyLeanback" parent="Theme.Leanback">
<item name="colorControlHighlight">#color/red</item>
</style>
However, this does not seem to have any effect. When I click and hold an ImageCardView, I still see the semi-opaque white circle.
How can I change the color of the ripple?
The solution was maddeningly easy:
<style name="MyLeanback" parent="Theme.Leanback">
<item name="android:colorControlHighlight">#color/red</item>
</style>
Note the android: prefix, which is required to override themes when not using AppCompat.
I had been dissuaded by the editor from including that prefix; it complained that it requires API21 (my application targets a lower version because it is a single .APK for mobile and TV platforms).
I have a ListView with some rows and a custom checkbox on the right hand side. On my OS 4.4 Nexus 4 it seems like a gentle gradient is being applied to the list row backgrounds, creating an ugly artifact on the checkboxes (they disappear half way down, and then invert for the bottom half). On other devices I don't see this problem, and I also don't see it in an OS 4.4.2 emulator.
I haven't been able to find any information online about this, so I'm not sure if it's specific to the device, or the exact OS flavor.
Is this something I can disable? If not, what advice should I give my asset designer?
Here's a screenshot:
The Holo.Light theme uses a subtle grey gradient background. It might only be more apparent on one of your devices due to the screen's contrast/brightness.
You can just set the background to solid white by using the android:windowBackground tag in your Activity's theme:
<style name="SolidWhiteTheme" parent="android:Theme.Holo.Light">
<item name="android:windowBackground">#android:color/white</item>
<item name="android:colorBackground">#android:color/white</item>
</style>
And then applying the theme to your activity in your AndroidManifest.xml like so:
<activity
android:theme="#style/SolidWhiteTheme"
...
>
...
</activity>
As Denley mentioned, the reason for this is the default background specified by the Holo.Light theme.
However, since this background is specifically affecting your ListView, I would suggest setting the background of your ListView in your xml file. Code below.
<ListView
android:background="#android:color/white">
Try specifying a background color for your activity (android:background). If the background is not explicitly set, the device may be using it's own device-specific default background, which is why the gradient is only shown on your Nexus 4 and not other devices.
I'm using ActionBarSherlock, but I'm not using any kind of of other theming. My application looks fine in the layout editor, because I'm using a certain color scheme that goes well with the white background shown. Although, when I run my application on a device 2.x, 3.x or 4.x, I get a very light gray color as the background, but it's definitely not white. Am I missing something? I thought the Light theme was a light gray action bar with a white background.
The Sherlock light theme is a copy of Holo.Light, which uses a very light grey as the default background colour.
You can override it to white it you like. In your application theme (create one if you need to which extends Sherlock Light), set the following attribute:
<item name="android:windowBackground">#android:color/white</item>