Reputation: 554
For Android Tv app I am using v17 leanback library and Leanback theme.
Having problems overriding default imageCardView background color.
<!-- original styles defined in Leanback theme -->
<style name="Widget.Leanback.BaseCardViewStyle" />
<style name="Widget.Leanback.ImageCardViewStyle" parent="Widget.Leanback.BaseCardViewStyle">
<item name="cardType">infoUnder</item>
<item name="infoVisibility">activated</item>
<!-- i want to override this -->
<item name="android:background">@color/lb_basic_card_bg_color</item>
</style>
<!-- In my styles.xml I inherit leanback theme and override imageCardViewStyle -->
<style name="AppTheme" parent="Theme.Leanback">
<item name="imageCardViewStyle">@style/myImageCardViewStyle</item>
</style>
<style name="myImageCardViewStyle">
<item name="cardType">infoUnderWithExtra</item>
<item name="infoVisibility">activated</item>
<item name="extraVisibility">activated</item>
<!-- set new color -->
<item name="android:background">#FADCA7</item>
</style>
Problem is that background color is always transitioned to defined "lb_basic_card_bg_color" in the Leanback theme, which I do not know how to override.
Another thing is that I did not find the method for setting content of the imageCardView extra card region. In the API I see only setTitleText and setContentText methods.
Upvotes: 1
Views: 2413
Reputation: 638
If you are using a Presenter (as in the Leanback demo), you could try to access the ViewHolder used with the ImageCardView and find the appropriate View with findViewById
.
Try this:
@Override
public ViewHolder onCreateViewHolder(ViewGroup viewGroup) {
mContext = viewGroup.getContext();
final ImageCardView imageCardView = new ImageCardView(mContext);
imageCardView.setFocusable(true);
imageCardView.setFocusableInTouchMode(true);
imageCardView.findViewById(R.id.info_field).setBackgroundColor(mContext.getResources().getColor(YOUR_COLOR));
return new ViewHolder(imageCardView);
}
As for the Extra, it is an ImageView that you set with imageCardView.setBadgeImage(Drawable here);
Upvotes: 2