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

查看:37
本文介绍了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 作为 的演示者>HeaderFragment 在您的 BrowseFragment 中.

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 用于包含 BrowseFragmentActivity.

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

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

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