AndroidTV-更改行标题的颜色[BrowseFragment] [英] AndroidTV - change color of rows header [BrowseFragment]
问题描述
I found something similar in SO: android-tv Changing text color and font of browse fragment rows header
以下主题答案是我提出的:
Following topic answer I came up with this:
<style name="CustomRowHeaderStyle" parent="Widget.Leanback.Row.Header">
<item name="android:textColor">@color/red</item>
</style>
但是,这不仅会更改行上方显示的文本,还会更改导航抽屉中的文本.我希望得到第一个答案(导航抽屉项目标题具有不同的颜色).
But this changes not only text that appears above the rows, but also navigation drawer text. I would love to get answer for the first one (having different color for navigation drawer item headers).
推荐答案
如果我正确理解了您的问题,则想在android leanback库的浏览器片段中更改行标题演示者的颜色.为此,您可以自行设计标题布局以实现此目标.首先,您需要设计一个自定义的android布局,将其命名为 custom_header_layout
if i understand your question correctly, you want to change color of row header presenter in browser fragment of android leanback library. for this purpose you can design header layout by your self to achieve this goal. first you need to design a custom android layout which lets call it custom_header_layout
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/text_view"
android:text="sample_text"/>
</FrameLayout>
然后,您需要创建新类并扩展ListRowPresenter,以将标题布局设置为浏览器片段,如下所示:
then you need to make new class and extend ListRowPresenter to set your header layout to browserfragment like this:
public class MainListRowPresenter extends ListRowPresenter {
public MainListRowPresenter() {
setHeaderPresenter(new MainRowHeaderPresenter(R.layout.custom_header_layout));
}
@Override
protected void onBindRowViewHolder(RowPresenter.ViewHolder holder, Object item) {
}
}
,最后扩展RowHeaderPresenter并将数据设置为浏览器片段中的标头:
and then at last extends RowHeaderPresenter and to set data to your headers in browserfragment:
public class MainRowHeaderPresenter extends RowHeaderPresenter {
public MainRowHeaderPresenter(int layoutResourceId) {
super(layoutResourceId);
}
@Override
public void onBindViewHolder(Presenter.ViewHolder viewHolder, Object item) {
//do something hear
}
}
有关更多详细信息,请查看这两个很棒的帖子浏览片段标题自定义和
for more detail please check these two awesome post BrowseFragment Header customization and BrowseFragment ListRow customization.
希望这会有所帮助:)
这篇关于AndroidTV-更改行标题的颜色[BrowseFragment]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!