I am currently trying to change the design of an EditText in Android Studio - specifically some colors. I was able to change the color of the cursor, the underline and the text, but not of the following object:
This "indicator" appears if one clicks at previously entered text (e.g. changing position of the cursor).
My questions are:
(1) What is this "Indicator" called? (Sorry if this is a duplicate. It's hard to search for something I don't know the name of)
(2) How can I retrieve the drawable of it, so I can add a color filter?
Thank you very much!
You need the change the accent color in your app's style.xml file. The style.xml resource file contains a style with the name "AppTheme" that are referenced from the app’s AndroidManifest.xml file to specify the app’s theme.
Setandroid:colorAccent to your desired color and you are good to go.
It depends on your colorAccent. Change your colorAccent code according to your choice and get edittext indicator same.
Related
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
How to get theme text color in layout xml? android:textColor="?attr/editTextColor" works for EditText color but I cannot find value for default text (TextView) color. I want to get text color to use in other elements.
If You Are Using Android Studio, Then Press Ctrl+B or Command+B (For Mac) On The Resource Name You Want to go to. As You are finding colour for textView. Then press ctrl + B, it will redirect you to the default style xml of android. You Can Find Shades There.
I find out default shades from the same source of course as Google has not given is every value of shades for every View.
Reply me back if it really helps you.
Happy Coding.
I am making an app and was wondering if there was a way to change a color resource value programmatically. For example, I am using the resource R.color.text_color_name to set the TextView text color. Is there a way to set that value to something different so that it would change the color of every TextView in the application?
The R file contains constants, you cant change them at runtime because you can't normally change constants at run time. If you want to update the color of all textviews why dont you look into themes. Create a custom theme and then change the theme when activity loads in onCreate. After you set the new theme i think your going to have to call setContentView again and then call all your findViewByIds again as they will be null. You could also try Calling recreate() after setTheme(). This sounds messy.
Maybe this can help you change the theme.
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.
I have the title color set correctly, but I'm not sure what I need to style to change the menu "icon" text color in the ActionBarCompat. I want the "Login/Join" text to be white.
Sorry, I'm sure the solution is out there on StackOverflow, but I haven't been able to string together the right keywords to find it :)
I couldn't figure out how to change that value programmatically or via xml aside from altering the base parent theme. I ended up changing my theme to inherit from Theme.AppCompat and set the titleTextStyle (https://stackoverflow.com/a/5881739/413254). I was inheriting from Theme.AppCompat.Light which naturally makes all text in the actionbar dark. Another option was to inherit from Theme.AppCompat.Light.DarkActionBar (which would have saved me a lot from multiple xml style headaches).
One of those situations where you get caught up in the details and miss the more fundamental things :P. Hope this helps somebody.