How to apply MaterialComponents only to some widget? - android

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

Related

android:background not work on button with theme Theme.MaterialComponents.DayNight.DarkActionBar

android:background and android:textColor not working on Button when application theme is "Theme.MaterialComponents.DayNight.DarkActionBar", but is works when theme "Theme.MaterialComponents.DayNight.DarkActionBar.Bridge".
I want to know why and how to fix this issue without changing the theme.
Ref:https://material.io/develop/android/docs/getting-started/
Bridge themes inherit from AppCompat themes, but also define the new Material Components theme attributes for you.
So if your button is not changing according to your wish you can use one of the bridge themes.
Theme.MaterialComponents.Bridge
Theme.MaterialComponents.Light.Bridge
Theme.MaterialComponents.NoActionBar.Bridge
Theme.MaterialComponents.Light.NoActionBar.Bridge
Theme.MaterialComponents.Light.DarkActionBar.Bridge

Tipsi-Stripe - How to Change Theme

I am using Tipsi-Stripe and NativeBase in my react-native, app, but I have not changed any theme variables (to my knowledge), but the components displayed from tipsi stripe seem be in some sort of "dark/night" theme.
Does anybody know where I should be looking to update these theme variables? I have looked at node_modules/native-base/src/theme/variables/ files, but they all appear to be nativebase defaults.
Screenshot:
NativeBase does not provide light or dark themes. It comes with commonColor, platform, material themes.
Though you can create light or dark themes on your own

Where can I find and modify the material color attributes in Android Studio as defined by the Material Design Guide?

Referring to the following Material design Guide
I want to modify the 12 different colors in my app e.g. Primary Variant, Secondary, etc.
However, in Android studio, when using the Theme Editor, the list of colors available to modify are different than what is specified in the material design guide. This is true no matter which theme I choose.
The 12 color variants as defined by both the Material Design and in the Theme Editor in android studio are as follows:
Material Design:
colorPrimary
colorPrimaryVariant
colorSecondary
colorSecondaryVariant
colorBackground
colorError
colorSurface
colorOnPrimary
colorOnSecondary
colorOnBackground
colorOnError
colorOnSurface
Theme Editor:
colorPrimary
colorPrimaryDark
colorAccent
android:colorBackground
android:colorForeground
android:navigationBarColor
android:statusBarColor
android:textColorPrimary
android:textColorPrimaryInverse
android:textColorSecondary
android:textColorSecondaryInverse
android:windowBackground
Are these colors just different names for the same thing or am I just looking in the incorrect place? I couldn't find anything in the material design documentation that that had names similar to what was in android studio so I'm a bit unsure.
Any guidance would be greatly appreciated!
The new colors attributes are not available on current stable version 1.0.0, however are available in latest 1.1.0 alpha:
implement "com.google.android.material:material:1.1.0-alpha05"
The documentation is ahead of implementation. You can check the release logs to have an idea:
https://github.com/material-components/material-components-android/releases

MaterialCardview requires Theme.AppCompat

I'm trying to test my skills on new Google Material components.
But for now I am encountering a problem with MaterialCardView
The building process tells me
The style on this component requires your app theme to be Theme.AppCompat
[..]
at com.google.android.material.card.MaterialCardView.<init>
With this clue I added
style="#style/Theme.AppCompat" & android:theme="#style/Theme.AppCompat" to the MaterialCardView and also to my Activity in the manifest.
I tried also to change my Acitivity to AppCompatActivity but without any success.
I also tried to set styles told by material.io documentation but without success !
Have you some clues?
Thanks
According to Material Components 1.2.1 you need to do this:
Depend on the library implementation 'com.google.android.material:material:1.2.1'
You'll need to have compileSdkVersion 30
Your activity needs to extend AppCompatActivity (or use AppCompatDelegate)
You have to use a Material Components theme
Source: https://github.com/material-components/material-components-android/blob/master/docs/getting-started.md
The easiest way to get started is for your current theme to extend Theme.MaterialComponents.*.Bridge instead of Theme.AppCompat.*.
Additionally you'll need to override the following attribute in your theme, otherwise the card color will be broken:
<style name="AppTheme" parent="Theme.MaterialComponents.Light.DarkActionBar.Bridge">
<item name="elevationOverlayEnabled">false</item>
</style>
Don't set android:theme="#style/Theme.MaterialComponents" on the card. You'll lose color information (primary, secondary, accent,...) from your theme on every widget inside the card.
Don't set style="#style/Theme.MaterialComponents on the card. Don't mix themes and styles.

Modify android theme from appcompat theme

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.

Categories

Resources