android-tv更改浏览片段行标题的文本颜色和字体 [英] android-tv Changing text color and font of browse fragment rows header

查看:112
本文介绍了android-tv更改浏览片段行标题的文本颜色和字体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在浏览片段中更改行标题的文本颜色和字体? 文本不在菜单中,而是出现在行上方的文本.

How to change text color and font of rows header in browse fragment?. The text not in menu but the text that appears above the rows.

推荐答案

我假设您正在使用提供的android.support.v17.leanback.widget.RowHeaderPresenter作为BrowseFragmentHeaderFragment的演示者.

I am assuming you are using the provided android.support.v17.leanback.widget.RowHeaderPresenter as the presenter for the HeaderFragment in your BrowseFragment.

RowHeaderPresenterR.layout.lb_row_header扩展布局,如下所示:

The RowHeaderPresenter inflates the layout from R.layout.lb_row_header which looks like this:

<android.support.v17.leanback.widget.RowHeaderView
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/row_header"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    style="?rowHeaderStyle" />

如您所见,它使用了名为rowHeaderStyle的样式属性,该属性通常指向@style/Widget.Leanback.Row.Header.您可以通过在styles.xml中放置以下内容来覆盖它:

As you can see, this uses a style attribute called rowHeaderStyle, which is normally pointing to @style/Widget.Leanback.Row.Header. You can override this by putting the following in your styles.xml:

<style name="MyCustomRowHeaderStyle" parent="Widget.Leanback.Row.Header">
    <item name="android:textColor">@color/red</item>
</style>

<style name="MyCustomBrowseStyle" parent="Theme.Leanback.Browse">
    <item name="rowHeaderStyle">@style/MyCustomRowHeaderStyle</item>
</style>

,然后在AndroidManifest.xml中声明MyCustomBrowseStyle,将MyCustomBrowseStyle用于包含BrowseFragmentActivity.

And then use MyCustomBrowseStyle for the Activity containing the BrowseFragment by declaring it in your AndroidManifest.xml.

这篇关于android-tv更改浏览片段行标题的文本颜色和字体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆