0

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?

Community
  • 1
  • 1
Myk Willis
  • 12,306
  • 4
  • 45
  • 62

1 Answers1

1

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).

Myk Willis
  • 12,306
  • 4
  • 45
  • 62