Change SherlockActionBar line color dynamically - android

I want to change the color of the bottomline of the sherlock actionbar.
But I want to change it dynamically.
When the user is offline I want it to appear red, when he is logging on I want it orange and when he is succesfully connected the line should be green.
How can I achieve this?
Thanks.

I found a solution in case anyone wants to do this.
I used this website to make 3 styles and took the 'ab_transparent' resource out of the zip.
To set the actionbar on runtime I used
getSupportActionBar().setBackgroundDrawable(getResources().getDrawable(R.drawable.ab_transparent_connecting));
Sidenote: this worked perfectly on android 4.0+ but on <4.0 I had to call
this.supportInvalidateOptionsMenu();
after setting the backgrounddrawable for it to take effect.

Related

Android Spinner Color style

Is there a way of changing the color of the Spinner control?
For example, Android 6 will render text with an arrow. I need to change the color of that arrow.
The change should apply to any version of android.
For example, Android 4 has underline with corner triangle. I have seen some approaches where you replace the icon that is being drawn, but that solution would not work for me. I need to change the color of the default icon.
Update
I have found how to apply style on Android Spinner using styles.xml,
<item name="android:spinnerStyle">#style/SpinnerItem</item>
but I cannot find what is the correct style to apply for the icon color to change.
It turns out, there is no nice way of doing this. It is possible to change the images used for the spinner, but then I would need to provide different set of images for each version, and also have conditionals / logic on the android code, to specify which set should be used based on version.

How to add a custom title bar with an image as background in android studio

I have found several answers on here as to how to change the background color and add a custom icon to the title bar in android studio but am having difficulties finding an answer for how to use a custom image as the background instead of just a color in the title bar. Any help would be much appreciated. Thanks.
sadly you cannot add images as the background on both the header and textView/webView that's why you don't see any apps on android with image backgrounds. you could try using html instead of xml, like:
replace colors.xml, styles.xml, ect with colors.html, styles.html, ect
but i doubt that will work. hopefully they will add this feature later in the android sdk.

android notification background color is not white on lollipop

As we known that Android lollipop force set the notification background color to white, so we can set the style of TextView according to different sdk version by putting style.xml in folder values-v21.
So here comes my question, on some third party ROMs, for example, the EMUI developed by Huawei tech co., the background of notification is not white(nearly black), by setting style to
android:TextAppearance.Material.Notification.Title
the color of the text is almost black, as a result, we cannot see the text clearly. I had been searching the internet for almost two days but find nothing helps.
I am trying to get the color of the notification background and set the text color dynamically, but I don't know how to accomplish this.
Need your help, thanks a lot.
Ok, so I just use the official API to set the notification info, that would inflate the default notification layout (status_bar_latest_event_content.xml)instead of my custom layout.
The rom changed the default background and text-color of the status_bar_latest_event_content.xml, but it wouldn't (or can't) change the custom layout.
mBuilder.setLargeIcon(combineBitmap).setContentText(notifyString).setSubText("fff");
remove the android:targetSdkVersion="21" from manifest.xml. it will work! and from this there is no prob at all in your apk it just a trick i apply this and i found colorful icon in notification and all features will remain same which u earlier use

android actionbar background color is grey instead of white

Is there any great solution that I could fix the problem ? I use #android:style/Theme.Holo.Light. My actionbar in Android 5 shows correct white. However, it's grey in Android 4. Do you guys have any idea? I search other solutions but none of them work. Please help me if you guys have any thought.
Just use a custom style, and color it white. Check here for more info

Android, change only clicked color of a button

I would like to change the default orange color that appears when someone press an Android button. I have done many searches but all I found was the use of selectors.
I understand the principle, but I don't want to modify the grey aspect of the normal button (not pressed). But using selectors force to define all characteristics of all aspects (pressed or not).
I don't know how to obtain the default aspect of buttons in the light theme, so can anyone tell me where I can find the original parameters of the light theme or at least give me another means to simply change the color of the button when clicked?
You can copy the Android's selector into your project, the one that Android sets it by default to buttons, and modify only the state when the button is pressed by just changing one single drawable.
You could find the file in \android-sdk\platforms\android-10\data\res\drawable\btn_default.xml
Sorry bro...........
i guess only selector will help you......
You must go with selector.....
and selector are reusable xmls you can use in all buttons.....:)
You can refer below link.
:)
http://developer.android.com/guide/topics/resources/drawable-resource.html#StateList
I tried to find a solution to this problem, but did not succeed.
Maybe this will help:
How to modify the default button state in Android without affecting the pressed and selected states?
Standard Android Button with a different color

Categories

Resources