Custom Actionbar icon compatible with other themes the user may choose - android

When creating custom ActionBar icons what happens if the user changes their theme to something that makes your icon unreadable? Do they have this kind of power?
Example: So say I make an icon for my ActionBar in Holo Dark, so that the icon will be a lighter shade of white. What if the user changes their theme to Holo Light (or can they in my app?), forcing my icon to not be readable because it is also close to the same color as its background? I'm just concerned that if I create a custom app it will not look proper to only certain people.
I have been trying to find something about this but my searches and Google's Iconography pages didn't really give me a clear answer.

Android allows setting a themes to application/activity in AndroidManifest.xml, and you can change theme theme dynamically. If a user change their system themes, it don't affect you application. If you want to change your application/activity themes, you should call setTheme() before setContentView() in Activity.onCreate()

Related

How to use only light mode in aplication? Android Studio

I'm developing a program, but as I have the mobile phone in the dark theme, some textViews have a white letter and don't appear due to the color that is placed on them.
But when I switch the phone to the lightweight theme, the textView all appear.
I would like to know if it is possible to disable the dark theme in Android Studio and only use the light theme, even when the phone is set to a dark theme.
Light Theme
Dark Theme
Just put this line in the launcher activity before setContentView()
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO);
This is a kind of short term solution if you don't want to properly implement dark theme in your app (the one that comes to the entire OS after A10)
Set your android:textColor=#android:attr/textColorPrimary which automatically choose the text color based on light or dark theme
Also, since you asked what to do to prevent from that default behaviour that switches your app to the dark mode when A10 and above devices turn on system wide dark mode then
You can make your Activity theme a descendant of Theme.MaterialComponents.Light or similar AppCompat variant . Currently all apps use Theme.MaterialComponents.DayNight which gives the default behaviour as above
If you decide to implement a system wide dark mode for your app, it's fairly easy, you can read about it here. Most of the widgets already come with dark mode support, it's just that you will have to do it for your own backgrounds etc
In your themes.xml your application theme's parent should be Theme.MaterialComponents.Light.NoActionBar, or if you wan't to use the action bar (you shouldn't), then Theme.MaterialComponents.Light.DarkActionBar

Android: Apply system theme to custom notification

Most new Android devices now provide an ability to switch between normal theme and some kind of dark theme. I've tested it on the Android emulator, and it seems that the emulator shows white notification panels even when the system is set to a dark theme, but on Samsung's device, the notification panels also becomes dark to match the system theme.
So, my question is, is it possible to make my custom notification (Button on a LinearLayout on a RemoteView) to match the system theme? That is, when the system is using the normal theme, I want to show a dark caption on a bright background, and when the system is using a dark theme, I want to show a bright caption on a dark background (the same colours as the rest of the notifications), and when the user switches the theme, I want my notification panel also to change the theme.
Is that possible? Please let me know, if it is impossible or very complex.

Is it possible to 'style' icons in Android?

For example, I downloaded an icon from Google which is simply a check mark. I put this icon in my app's action bar but unfortunately the icon is black and my action bar is quite dark so it doesn't look good. Is there a way to style the icon automatically or do I have to edit the png to be white instead? I found this website which mentions styling an icon but I'm not sure if that's a guideline for a designer or actually something that goes into code.
What is the standard way to style icons? Do I need to download black and white icons and use the appropriate one at runtime based on the app theme? That seems like it could be a pain.
For myself, if I need to style an icon, I use photoshop to edit the icon. But any image processing software should work if you are familiar with it.
However, the icons you mentioned that are available online usually come with both a dark and light theme. So if you have a dark action bar theme, you can simply download and use the light version of the icon.
For your checkmark icon specifically, you can download either the light or dark version of it here, here, or here. Hope this helps.
look at this web site http://bitdroid.de/Android-Material-Icon-Generator/
for any question or how it work: http://forum.xda-developers.com/tools/programming/tool-android-material-icon-generator-t3333159

Translucent icons in ActionBar when disabled: only on my phone?

I'm using ActionBarSherlock on my app and when I disable some MenuItem in the ActionBar the icon turns translucent on my phone (HTC One X running stock Android 4.0.4) but I haven't seen this behavior in any other phone or emulator.
Am I right in assuming this behavior is not the default one for the native ActionBar? I like the idea though... It warns the user that the MenuItem is not enabled for some reason (in my case, it's a save button and if at least one field is not filled, it disables the button).
I was thinking in providing myself a translucent icon and set it manually when the MenuItem is disabled. This will work on every Android version, native ActionBar or not. The problem is that on my phone (or any other with the same behavior for that matter), it will be twice as translucent and I don't want that.
Any ideas on how can I properly achieve this effect?
I think that the problem is on the Theme, you are applying the default theme. So, HTC override default theme resources, i think you have to create a custom theme and change the item_background to the default one on sdk resources.
<item name="selectableItemBackground">#android:drawable/item_background</item>
you would have to set the background to be independent of the theme. In the .xml file you could set :
android:background="?android:attr/listSelector"
on the view where you want the color.

Android Theme.Translucent on ICS render all the child elements as gingerbread

I am developing an Android application where I have set the following theme to one of my activities so that I have a nice translucent background.
android:theme="#android:style/Theme.Translucent.NoTitleBar"
This works pretty well with versions before 14 (ICS), but on ICS, although the activity is shown with translucent background, all the elements inside the activity start using Gingerbread theme. i.e. the buttons inside the activity are displayed with yellow highlight when selected instead of blue on ICS. Similarly, a spinner button when activated/clicked display the items as dialog instead of ICS popup/popdown style.
Can anyone please help me on how to get the translucent background along with the ICS theme?
To have the blue highlight from ICS and up you need to use a Holo theme, all other themes will render components as if they are being displayed on Gingerbread and below because that is how the theme is telling the system to render them.
You could extend the Holo theme of your choice and use the members from the translucent theme which will give you your desired effect on ICS and above.
The theme data is available in <android-sdk>/platforms/android-<API-level>/data/res/

Categories

Resources