Ripple color on ImageCardView in Android TV - android

I am using the Leanback library for an Android TV application, and I am using the typical BrowseFragment that uses ImageCardViews for navigation. The ImageCardViews show a ripple effect when clicked: a semi-opaque white circle starts in the middle and grows to fill the View.
I am trying to change the ripple color to match my app's primary color. My application uses a custom Theme that inherits from Theme.Leanback, and I thought (based on e.g. https://stackoverflow.com/a/31922339/925478) that I could change the ripple color by overriding the colorControlHighlight attribute in the theme:
<style name="MyLeanback" parent="Theme.Leanback">
<item name="colorControlHighlight">#color/red</item>
</style>
However, this does not seem to have any effect. When I click and hold an ImageCardView, I still see the semi-opaque white circle.
How can I change the color of the ripple?

The solution was maddeningly easy:
<style name="MyLeanback" parent="Theme.Leanback">
<item name="android:colorControlHighlight">#color/red</item>
</style>
Note the android: prefix, which is required to override themes when not using AppCompat.
I had been dissuaded by the editor from including that prefix; it complained that it requires API21 (my application targets a lower version because it is a single .APK for mobile and TV platforms).

Related

How come the color I set for cardBackgroundColor isn't exactly the one that gets shown?

Background
I'm trying to prepare dark theme for an app, and one of the requirements is to have a specific color for cards and dialogs : #ff3c454c
The problem
Whether I set it by force ( app:cardBackgroundColor="#3c454c") , by reference ( app:cardBackgroundColor="#color/...) or just in the theme - in all cases I don't get the color I've set. Instead I get the color of #525A61.
I've tested just a red color (#f00) just to be sure it affects the card, and it does, and for this color it indeed gets to be fine. But for the color I've set, it doesn't.
What I've tried
As I wrote, I tried multiple ways to set the color. In the beginning I wanted to use just the theme itself, so I've set it as such:
styles.xml
<style name="AppTheme" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
...
<item name="colorBackgroundFloating">#color/colorBackgroundFloating</item>
<item name="colorSurface">#color/colorBackgroundFloating</item>
</style>
res/values-night/colors.xml
<color name="colorBackgroundFloating">#ff3c454c</color>
Later I tried to use the color directly and even set it as hard coded. Still got the incorrect color when it gets shown.
Seeing this could be a bug on the library itself, I've reported about this here (include a sample project, if you wish to check it out).
I've noticed the exact same issue occurs for BottomNavigationView and probably other similar cases.
The question
Why does it occur?
Is there any workaround for this?
Something that will fix it globally for all views that use these attributes ?
What you are seeing is the elevation overlay that they introduced to make elevation more noticeable while in Dark Theme, where shadows are not so visible. You can read about it here : https://material.io/develop/android/theming/dark/ in the section "Elevation Overlays"
The simple solution if you don't want this behavior is to add this to your theme.
<item name="elevationOverlayEnabled">false</item>
And you can also adjust it to another color or even a more subtle version of the overlay by changing the alpha:
<item name="elevationOverlayColor">#80FFFFFF</item>
EDIT with more info from https://github.com/material-components/material-components-android/issues/1133
If you want to disable it for only one component or widget, you can define a style for it with a theme overlay and use it in a specific layout:
<style name="ThemeOverlay.MyApp.ElevationOverlayDisabled" parent="">
<item name="elevationOverlayEnabled">false</item>
</style>
<style name="Widget.MyApp.CardView" parent="Widget.MaterialComponents.CardView">
<item name="materialThemeOverlay">#style/ThemeOverlay.MyApp.ElevationOverlayDisabled</item>
</style>
And if you want to disable it for all cards in your app but keep it in other components you can set that style as the default style for material card views:
# Set in your app theme
<item name="materialCardViewStyle">#style/Widget.MyApp.CardView</item>

Tint Navigation Icon in Toolbar

How to tint menu icons is already covered a few times, like here:
Toolbar icon tinting on Android
Additionally to this solution there is still the problem of the navigation icon.
Applying a Theme(Overlay) to your Toolbar just tints the text and the whitelisted icons (see: https://stackoverflow.com/a/26817918/2417724)
If you set a custom icon (which happens to be quite easy the case, as you need to change it if you don't want to display the default back arrow) then this custom icon does not get tinted.
How do you handle your Icons then?
All my icons are per default black and I don't want to have special white versions just to use them in the Toolbar then.
The appcompat navigation button - which is simply an AppCompatImageButton - can be styled through the toolbarNavigationButtonStyle attribute. The default style for that in the AppCompat themes is Widget.AppCompat.Toolbar.Button.Navigation, and we can extend that style to add a tint attribute value. For example:
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
...
<item name="toolbarNavigationButtonStyle">#style/Toolbar.Button.Navigation.Tinted</item>
</style>
<style name="Toolbar.Button.Navigation.Tinted" parent="Widget.AppCompat.Toolbar.Button.Navigation">
<item name="tint">#color/nav_button_tint</item>
</style>
There are a couple of caveats to be aware of when using this method.
Prior to support library version 25.4.0, AppCompatImageButton did not offer its own tint attribute, and therefore a tint attribute in the app's namespace will not apply (and just won't exist, unless defined elsewhere). It is necessary to use the platform android:tint attribute if using support library version 25.3.0 or earlier.
Unfortunately, this leads to another catch, in that the platform tint prior to Lollipop (API level 21) can handle only simple, single color values, and using a ColorStateList (<selector>) resource value will cause an Exception to be thrown. This poses no problems if the android:tint value is a simple color, but it is often desired to tint the navigation icon to match another theme color attribute, which may very well be a ColorStateList. In this case, it would be necessary to create separate styles in res/values/ and res/values-21/, specifying a simple color value for android:tint in res/values/.
For example, if tinting to match the theme's primary text color:
res/values/styles.xml
<item name="android:tint">#color/normal_text_color</item>
res/values-v21/styles.xml
<item name="android:tint">?android:textColorPrimary</item>
You need only concern yourself with the notes above if you're stuck using a support library version less than 25.4.0.
To effectively set the tint color of the navigation icon programmatically you need to set the drawable first and apply the tint afterwards.
toolbar.setNavigationIcon(R.drawable.ic_back)
toolbar.children.forEach {
(it as? AppCompatImageButton)?.imageTintList =
ColorStateList.valueOf(Color.GREEN)
it.refreshDrawableState()
}

react-native android: How to change the color of ListView "end of scroll" animation?

How can I change the color of the animation?
The color is based on your accentColor in your AppTheme.
To change it, change your AppTheme (generally in res/values/styles.xml) to:
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat">
<!-- Customize your theme here. -->
<item name="colorPrimary">#F00</item> <-- change to color
<!-- Status Bar color -->
<item name="colorPrimaryDark">#000</item>
<!-- Details color -->
<item name="colorAccent">#000</item>
</style>
Beware it's an global app change, every scrollview bounce animation will have this color.
To change only the overflow animation color, use android:colorEdgeEffect. Otherwise it will be inherited from the colorPrimary in AppTheme.
The accepted answer should be changed to specify colorPrimary instead of colorAccent.
See answer here: android lollipop scrollview edge effect color
Put this inside android/app/src/res/values/styles.xml
<item name="android:colorEdgeEffect">#E53644</item>
if someone is using expo managed app, it's not supported by expo yet, but there's a workaround.
you'd need to expo eject -> to transition to bare workflow. then as said above within android/app/src/res/values/styles.xml add
<item name="android:colorEdgeEffect">#E53644</item>.
now the worst part which took me hours to figure out - you'll have 2 themes generated by default the AppTheme and Theme.App.SplashScreen, it didn't work until I've added it to splashscreen one :/. I've added it to both themes just in case. note that this specific change will work only when you run android specific native build npm run android, for more please read this
I'm using Expo managed workflow + react native paper with Material UI v3 and in debugging the color of the "ripple" was purple.
But luckily, when I test it over the Google Play Store, it was based on the primary color (or primary container color).
PS: I had similar issues with the color of dialog buttons and the app icon being not shown correctly.

Android - Material Theme

I'm trying to implement Material Theme with SDK 4.0.0. Here are some issues I have:
9 patch splash (background.9.png) isn't displayed correctly. Worked fine before (logo centered with all white background, no black spots).
here is my custom theme:
<style name="MyMaterial" parent="#style/Theme.AppCompat.Light.DarkActionBar">
<item name="colorPrimary">#4CAF50</item>
<item name="colorPrimaryDark">#388E3C</item>
</style>
There are some windows opened dynamically that I want to have different colorPrimary/colorPrimaryDark than the defaults above. Is it possible?
My app uses a tab group. There is a underline underneath an active tab. I want to change the underline's color to #ffffff without affecting other controls' active color. Unfortunately colorAccent affects all controls' color. What should I do?
Can I remove the default tab divider and add shadow underneath so that the tabs look like the Google Play Store app's?
My app uses push notification. I usually specify my appicon.png for the notification's icon. Now upgraded to SDK 4.0.0 with Material Theme, the appicon shown in the notification becomes all white. Can I show the regular appicon instead?
Since Android 5.0, you need to provide the until then optional padding box for nine-patch images. The newest version of the TiCons CLI generates this for you: http://npmjs.com/package/ticons. You need black pixels on the bottom and right side of the image, except for the bottom left + right and top right pixel.
You can define multiple themes and then use the theme property in createWindow() to select one.
Android's new Material Design Theme has limited options in what you can style. See https://developer.android.com/training/material/theme.html
See previous
Not sure about this one but did you check http://docs.appcelerator.com/platform/latest/#!/guide/Sending_and_Scheduling_Push_Notifications-section-43298780_SendingandSchedulingPushNotifications-icon?

Android AppCompat 22.1.1 default text color and ActionMode style

I am updating my application to use the version 22.1.1 of the Android Support Library. My application theme inherits from Theme.AppCompat.Light.DarkActionBar.
It works fine, except that all texts are white if the TextView style is set to one of the predefined style. So I end up with white texts on light background (default background color). With version 22.0.0, I had no issue.
I tried the follow in my theme, but it does not seem to work:
<item name="android:textColor">#color/black</item>
<item name="android:textColorPrimary">#color/black</item>
<item name="android:textColorPrimaryInverse">#color/black</item>
Moreover, the ActionMode now has a black background instead of white, as it used to be with 22.0.0.
Any idea on how to change this?
I was using the theme attribute in my theme to set the Toolbar theme. That's a mistake. The Toolbar theme has to be defined on the Toolbar tag directly.
For the ActionMode background color, it looks like I was taking profit of a bug without knowing it.

Categories

Resources