2

In android tv using leanback library, we pass button text as CharSequence to populate action items in details overview : new Action(long id, CharSequence label1, CharSequence label2, Drawable icon)

A little context here: if you visit a details page of a movie (say, Arrival) you will notice action buttons: "watch trailer", "rent for $10.00", "own for $20.00"

I am looking into ways to change text-color / text-style of these action items, but have been unsuccessful so far.

Any ideas?

Here is a snippet of my code:

 SpannableStringBuilder spannableStringBuilder = new SpannableStringBuilder(price);
 spannableStringBuilder.setSpan(new ForegroundColorSpan(Color.RED), 0, spannableStringBuilder.length(), 0);
 addDetailsOverviewRowButton(1, "OWN FROM", Html.fromHtml(spannableStringBuilder.toString()), getResources().getDrawable(R.drawable.xyz, null));
Vpd
  • 235
  • 2
  • 12
  • What does your code look like that doesn't work? Please provide a [Minimal, Complete, and Verifiable example](http://stackoverflow.com/help/mcve) that demonstrates the issue. You may also check on this [SO post](http://stackoverflow.com/questions/33774150/android-tv-changing-text-color-and-font-of-browse-fragment-rows-header) for reference. – abielita Feb 18 '17 at 11:57
  • abielita, your reference is a bit different that what I am trying to accomplish. Also I want to be able to change the text style for a specific action item. Thanks, though. – Vpd Feb 21 '17 at 19:12

1 Answers1

0

create style with parent Theme.Leanback.Details there you can add item as

<item name="detailsActionButtonStyle">@style/Theme.Detail.Action</item>

then create another style as in above item.

<style name="Theme.Detail.Action" parent="TextAppearance.Leanback.DetailsActionButton">
        <item name="android:textColor">@color/detail_action_text_color</item>
        <item name="android:textAppearance">@style/TextAppearance.Leanback.DetailsActionButton
        </item>
        <item name="android:background">@drawable/detail_action_selector</item>
     </style>

Here, detail_action_selector is the drawable file which changes the background on action focused and unfocused.

A_rmas
  • 784
  • 2
  • 10
  • 26