Is there any way to change an attribute from the stock android themes, if the App is using the AppCompat theme?
My Problem:
I am using AppCompat theme in order to get the L-Look.
But I need to use the ActionMode, which is from basic Android API.
If I change the ActionMode style within my AppCompat theme, the style for the SupportedActionMode is applied.
But i defintily need the basic API ActionMode.
Does anybody know a way how to do this, in order to style my ActionMode background?
Use ActionMode properties' names without android: prefix.
Related
I am migrating from AppCompat to MaterialComponents, and I would like to keep some widgets (like the Bottom Navigation Bar) AppCompat-themed. However, when I want to apply MaterialComponents theming to Buttons and TextFields, I must set my app theme to MaterialComponents.... and therefore all my widgets are MaterialComponents-themed. How can I make only some widgets MaterialComponents-themed ? I have been looking for an answer on StackOverflow but couldn't find anything.
You can use Bridge themes like :
Theme.MaterialComponents.Bridge
Theme.MaterialComponents.Light.Bridge
Theme.MaterialComponents.NoActionBar.Bridge
Theme.MaterialComponents.Light.NoActionBar.Bridge
Theme.MaterialComponents.Light.DarkActionBar.Bridge
Bridge themes inherit from AppCompat themes, but also define the new Material Components theme attributes for you. If you use a bridge theme, you can start using Material Design components without changing your app theme. (From documentaion)
Have a look : Get started - Material Design
I'm using Toolbar as setSupportActionBar(toolbar). How i can change action mode background color. I try in my App Theme change attribute:
<item name="android:actionModeBackground">#color/color</item>
But it is not working. How can I solve this problem?
The AppCompat library supports versions of Android that don't have ActionBars, so it needs to define attributes to use that wouldn't exist on those devices. You want to use this:
<item name="actionModeBackground">#color/color</item>
The same goes for any other style/theme attributes you want to use that have been backported. But you'd use platform ones that exist, like android:textColor or android:background.
While trying to update my app to a material design look, I added Appcompat v7 library to my project(last update), Everything works well for now but I'm forced to declare a theme in the manifest (wich I wasn't before working with Appcompat Lib).
Theme.AppCompat.Light
And when I change the theme in my app with
setTheme(pink);
the status bar color choosen with
name="colorPrimaryDark">#color/pink
stays the same color as in the theme declared in the manifest.
So here is my question how can I change the status bar color?
I found the proper solution to all this, the
setTheme(theme);
method should be called before
super.onCreate(savedInstanceState);
You can use getWindow().setStatusBarColor(color).
I used google but didn't find an accurate solution, for changing themes programmatically.
I want to change everything programmatically: styles, colors, attributes etc., without using style.xml, theme.xml or any other xml file.
I have searched, but styles are defined in an xml file like that Using Themes in Android Applications
I know this is an old question, but if someone's still looking for a solution, checkout the GreenMatter library for the Material theme, or for the Holo theme holoaccent.
I would like to deploy my app on APIs 8-17. However, for purely aesthetic reasons I would like to apply the default theme as it appears on api 8 as the theme for the app across all API levels.
For example, the older theme has an edittext that has an orangeish border around it, whereas the newer them uses a borderless blue line.
By limiting which APIs i deploy too I have been able to accomplish this but that isn't really a solution.
Does anyone know how this can be accomplished?
Thanks
Update
For whatever reason applying "Theme" as the theme did not force it to revert to the "Theme" theme, but instead left it as the default Holo. Using the answers below I simply called "Theme" as the parent in my custom theme (without altering any of its attributes) and set it as my application theme in the manifest. This solved it.
In your res/values directory, you can have a themes.xml file with:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Theme" parent="#android:Theme">
</style>
</resources>
Your app theme will now subclass from default Theme instead of Theme.Holo and you should be able to get older theme on newer android versions as well.
If you're using the default theme, it will be different between the API levels. However in the styles, you can create a custom Theme, modify an existing Theme or give a different Theme to each different API of your choice.