Change the default onPress color in Android - android

On my Galaxy S3, by default when buttons are pressed their backgrounds take on a light blue color. Is there a way to change this color?
I am aware of State List Drawables, and I've been able to use them to do this in certain situations. However, there are some things that still use this default color that I would like to change. For instance:
The home button in the Action Bar still uses the light blue color when it's pressed
The display buttons in a MapFragment (zoom in, zoom out, my location, etc.) still use the light blue color
If anyone knows how to change this color in general across the entire app, or even for just these two instances, that would be very helpful. Thanks.

Related

Drawable color changes, but after changing activity remains

I have a menu, with several buttons and its drawables. This menu is included in 4 activitys.
I am setting the drawable color programmatically:
mDrawable.setColorFilter (0xff0099cc, PorterDuff.Mode.SRC_IN);
The first button by default is enabled, so the color is changed programmatically. When I press another button to go to another activity, the other button changes the color, but the first one remains as if it had activated.
You are not clear about your drawable and so I ll give generic solution to you.
You can just use Drawable.setColorFilter( 0xffff0000, Mode.MULTIPLY ). If you could make the entire image WHITE (FFFFFF) so that when you do PorterDuff.Mode.MULTIPLY, you end up with the correct colors. Note this would not affect the transparent pixels.
For solid images, it is best to use the color filter PorterDuff.Mode.SRC_ATOP because it will overlay the color on top of the source image, allowing you to change the color to the exact color you are looking for.
Let me know, whether it helps.

BottomNavigationBar - how to change the colour

The source of this component is :
https://github.com/pocheshire/BottomNavigationBar
I have a bottom navigation bar in an Android App with 4 tabs on.
I want to set the background colour to be the same regardless of selected tab
I want to show icon + text for all tab buttons regardless of whether they are selected or not.
The background colour defaults to White. The only way I can find to change it is to call setActiveTabColor() for each Tab. This works but seems like overkill I should only need to set it in one place.
However the real problem is as follows :
I cannot show the text for all icons unless I call useFixedMode();
However once useFixedMode() is called, SetActiveTabColor no longer works and the I cannot then set the background colour - it defaults to white.
I have also tried SetBackgroundColor(); to no effect
What am I missing ?

android : what decided edit text default border colour on focus

I have two different apps and how the edittext appears in both are different. In one when i focus , the border is getting an orange colour and in other app its blue. I am not setting background in either the app. So how is the difference coming. Is it the android version selected ?
The default styling of widgets is controlled by the theme used by the activity. From your described symptoms, my guess is that you have not specified any theme, which means that you will get an orange focus ring on Android 1.x/2.x, a blue border on Android 3.x/4.x, and IIRC a gray border (subject to custom tints) in Android 5.0+.
More tactically, the focus is part of the EditText background, which will be a StateListDrawable pointing to other drawables for the various states (normal, focused, disabled, etc.).

Override list item background color with white, keep system default (long)pressed color

How can I replace the color of a listview item background when in the non-(focused|pressed|activated) state with a custom color, but keep all the system default colors for pressed, long-pressed, activated, focused etc. states?
I'm trying to give my listviews a card style - that is white items with space in between on a grey background (as in Google Play Store app and others).
So I want to give the items a white background, but at the same time, keep all the system default selectors, including the fade animation for long press. That is, I want to replace the transparent color for the inactive states with white, but keep all the other states as by default.
This is even more important since the KitKat release, because all the accents have now switched from blue to grey, so I would like the app to respect that - to have blue color when pressed on ICS and JellyBean, but grey on KitKat. Therefore, I don't want to hard-code any values into a custom selector.
All right, I figured it out and it's incredibly simple:
All I have to do is to add this attribute to the given ListView:
android:drawSelectorOnTop="true"
And that's all! I can give the list items any background color that I want and it will always be overlayed by the system default selector!

Change the truck color of a listview in android

I'm not sure if it's called the truck in the world of java, but I've always referred to the scroll bar size thing as a truck. That bit on the right that gets smaller as there are more items in the list, and that stays relative to the current scroll position. Truck? Right?
Well regardless of what it's called, does anyone know how to change it from white to another color. I've a list with green text in it, and in fact all my controls are green on a black background. It looks quite spunky and fun. But for the "truck"; it remains white.
Does anyone know how to change the truck color?
Just do
android:scrollbarThumbVertical="#drawable/scrollbar_vertical_thumb"
and let scrollbar_vertical_thumb be a gradient
refer to this

Categories

Resources