Is there a way to replicate the color changing ability provided by QKSMS .
It allows a user to select a color and then changes the app color and everything to that color.This is all done dynamically the moment the user chooses a specific color.
You can try this cool online tool: http://android-holo-colors.com
This enables you to create many themes for app widgets with your preferred color. You can then change your app theme by saving values for your theme in SharesPreferences or something similar and apply them in onCreate of each activity you have in your app. You can also create the themes easily in styles.xml. For each view, it has its own style with its own attributes so you will need to learn how to edit the theme of each view you want by searching...
Hope that helps.
Some Examples:
ActionBar:
https://developer.android.com/training/basics/actionbar/styling.html
Buttons:
https://www.androidcookbook.com/Recipe.seam?recipeId=3307
SeekBar:
Android - styling seek bar
Switch:
How can I style an Android Switch?
And a lot more... You will have to search for what you want.
Related
I have a android custom view that start a custom action view when long clicked, as such, it require the theme of the activity to have the style "windowActionModeOverlay" set to true. I don't want to define a custom theme. I want to use whatever theme the user provided for the activity, and set the style to true at runtime using code myself.
Is this possible ?
Please note any suggestion by changing style xml file is not what I am looking for, unless it allow user to use whatever theme they choose for their activity.
Thanks
There are tons of solution for changing the style of a single view. There are tons of solution for changing theme at runtime, but I only want to change a single style of a theme, and so far, I can not find a solution myself or online
I'm building a material design playground that can switch between the available pre-defined themes that can apply the color, typography and shapes to all the material design components throughout the app.
Right now, the user can choose available themes from the PreferenceScreen:
I got a NEW requirement that should allow the user to enter a value (eg. set color of colorPrimary). From the input, I would like to modify the Theme directly so that it could apply the change in the app.
How can I do this? I'm thinking of giving an option to the user something like below:
Here's a link to my sample material design playground app:
https://github.com/ciscosoriano/material-design-dynamic-theming
Seems like you need something like this android-how-to-change-application-theme-programmatically
link: android-how-to-change-application-theme-programmatically
This should be easy and there are lot of tutorials out there, don't forget to checkout
Basically what you need to do is:
apply statically defined theme(in res/values) as usual before activity is launched.
Now get the user input when activity is launched
Then get the current theme attributes using appropriate api and recolourize the ui controls dynamically in the program.
restart activity with the updated theme.
Some more link: Set theme color dynamically
You should be comfortable handling the activity lifecycle to view the updated theme when set.
Its not so long since I started to program in Android Studio. I was wondering why everything that I'm adding (like button, the actionBar...) has already a Lilac predefined color and how I can change this color. When I tried to change the color of the button in xml of my activity nothing happened.
android:background="#color/teal_200"
Can you help me please to know where I can change this default color and why the
android:background="#color/teal_200"
didn't worked?
Thank you!
These elements will likely be in an activity and that activity will have a theme, which you can check by looking at the android:theme of the activity (or the application, if the activity doesn't have one) in AndroidManifest.xml.
If you've started a new project from a template, this theme will likely be in res/values/themes.xml and it will define colours that will be used wherever that theme is applied.
Different elements take different colours from the theme and you need to check the documentation for each one to understand where their colours come from and how to change them.
For example, if you're using a contained MaterialButton, its documentation is here. There you can see that it takes its background colour from the colorPrimary of the theme by default and this can be overridden by setting the app:backgroundTint of the button. Therefore, if you wanted to change the colour of all the contained buttons in activities that use that theme, you'd need to change the colorPrimary of the theme. You could also change the colour of individual buttons by setting the app:backgroundTint of each button.
Note that several UI elements also use the colours set in the theme (like colorPrimary) and they'll change if you change those values. There's more info about what the colours in the theme are used for here, here and here and more general info about themes and styles here.
please change in colors.xml in your resource file
Open values -> colors.xml and add the color you want and set it in the layout XML file
To add the gradient background somebody suggest to use android:background and others say android:theme.
android: background will set the background in your current view/layout.
Themes on Android allow you to separate the details of your app design from the UI structure and behavior, similar to stylesheets in web design.
A theme is more of a collective thing which has its impact on overall UI of your screen. Like the color of the action bar, the color of the line in your edit text etc.
You can read more details about themes here.
Does anyone know how to apply the Light theme to single controls? While using the standard Holo-Dark-theme, I want to do something like this:
<CheckBox style="#android:style/Widget.Holo.CompoundButton.CheckBox"></CheckBox>
But for some reason that doesn't work.
You can not apply a theme to a single control. Themes can only be applied to activites. You can apply a style to single control but this does not help in this case as you already noticed because the Widget.Holo.CompoundButton.CheckBox style does not add anything to the parent style Widget.CompoundButton.CheckBox.
Instead the whole styling takes place in the listChoiceIndicatorSingle selector of the current theme.
So your only choice is to replace this selector by your own as described e.g. here: Setting Theme.Holo.Light changes everything except checkboxes in list
Read up on this page about Styles and Themes in Android. It goes over how to define which theme to use for a specific Activity or a whole Application. You will also see how to customize themes and styles, and how to mix and match them.