This question already has answers here:
Closed 11 years ago.
I have been trying to change the background color of the app widget on the fly for sometime now, with no success.
I had found one solution (http://stackoverflow.com/questions/2726295/android-changing-linearlayout-in-a-widget) which we have been using.
Problem is we already have 8 layout files for 8 background colors, which is really difficult to maintain.
We would also like to add a color picker so that users can select their own choice of color.
Is there a better way to work around the RemoteViews limitations?
Thanks...
Won't
android.view.View.setBackgroundColor(int color)
do the trick? The color is a 32 bits made up of four 8-bit values for alpha, red, green and blue. See android.graphics.Color for details, it also has helper functions for selecting colors. Or is that not supported by RemoteViews? I suppose it would correspond to
views.setInt(R.id.my_ll,"setBackgroundColor",myColor);
as stated in your link, don't know if that works though.
HTH.
Related
I have colors of text and button come dynamic form backend,
I need to change this color of text dynamically when change happens in backend all at time.
I could make it manual
textView.setTextColor(getResources().getColor(R.color.text_color));
Is there a way to change group of text color dynamically or must set every text color manually in code?
I searched for how to change theme colors dynamically at run time and i found this answer this answer.
But I also search again and I found this github
but it doesn't work on Android Marshmallow (6.0+) and it's use is discouraged! as he say.
Is there any lib or method to change the theme on runtime?
So far it's impossible and not viable because of themes are immutable.
GreenMatter becomes outdated so regretfully the answer of your question is No way.
More precisely, the color overriding at runtime is not working. There is no fix found at the moment. The future of this feature is uncertain.
This question already has answers here:
Android changing Floating Action Button color
(26 answers)
Closed 6 years ago.
I am novice for the android world. Just for improving my skills, I am learning android. So I am creating a social app there I have used floating action button, on which if user clicks it increases the number of likes.
By default, floating button is taking accent color but I want to use different color. I tried a lot but not getting any solution. Yes, there are so many libraries available that I can use to achieve my goal, but I do not want to use any external library. I believe to use core methods of android.
Is it like, there is no solution except using external libraries? I tried this one, but xml file is throwing error when I am using app tag.
If you wish to change the color
in XML with attribute app:backgroundTint
in code with .setBackgroundTintList
I am using this library:
com.android.support:design:23.1.1
Please comment on the same. I know for Android guru's this is not big deal. I know this question has been already but I didn't get solution for my problem. That's why I am opening this question again.
As described in the documentation, by default it takes the color set in styles.xml attribute colorAccent.
The background color of this view defaults to the your theme's colorAccent. If you wish to change this at runtime then you can do so via setBackgroundTintList(ColorStateList).
If you wish to change the color
In XML with attribute app:backgroundTint
<android.support.design.widget.FloatingActionButton
xmlns:app="http://schemas.android.com/apk/res-auto"
...
app:backgroundTint="#color/orange"
app:borderWidth="0dp"
app:elevation="6dp"
app:fabSize="normal" />
in code use setBackgroundTintList
This question already has answers here:
Why is my Button text forced to ALL CAPS on Lollipop?
(20 answers)
Closed 8 years ago.
I have a simple homescreen widget with a few buttons on it. My problem is that when the widgets are running on Lollipop the button's text are all capitalized, any previous Android version doesn't have this problem. The buttons in the layout.xml are very ordinary buttons: no styling or special sauce, just a width height and text size. The interesting thing is that any TextViews I place into the widget aren't affected by this in Lollipop, ie. it appears that only Button objects have this issue.
My AppWidgetProvider is pretty simple too: just sets the sets the text and a PendingIntent for each button.
It sounds like a global styling problem, but I can't find anything in my application's resources that would cause this. Does anyone have any input to this problem? Thanks!
You have 2 options :
1.Use android:textAllCaps="false" in your layout-v21 (or anywhere)
Programmatically change the transformation method of the button. mButton.setTransformationMethod(null);
In my app, I will have a ListView with read and unread items, so I would like to use the same colors than the latest AOSP.
The 2 grey color shades of the messaging app sounds quite correct and I would like to know where I can have a look in Android source code to find the exact same grey. (read = white?)
Note: using a screenshot and a color picker is not acceptable, I don't want to "guess" the correct hexadecimal code.
I am totally aware that I could use my own colors, but using the system one sounds better.
The Android design website doesn't give me any clue at the color section: http://developer.android.com/design/style/color.html
Any idea/suggestion?
The lighter color is: #FFFFFF
The darker color is: #EEEEEE
I use the Eye Dropper Chrome Extension to figure out color codes from any web page
This question already has answers here:
Standard Android Button with a different color
(20 answers)
Closed 3 years ago.
I have been looking at these posts:
StateList
, Different states
What I really want is to add an outer-glow or some way to highlight the button onclick versus making different images for the associated states. Is this possible using colors or themes?
Thanks in advance :)
EDIT:
I found a good solution here, not quite the right answer but a good one none the less:
standard-android-button-with-a-different-color
I think you will be better off making an image for the state rather than trying to use software to render this automatically. The software solution will most likely be slower.