AndroidTV - change color of rows header [BrowseFragment]
Asked Answered
C

2

3

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).

Caucasoid answered 13/9, 2017 at 13:14 Comment(0)
T
3

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>

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) {

    }
}

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.

hope this helps :)

Turnspit answered 14/9, 2017 at 5:53 Comment(0)
G
0

<item name="rowHeaderStyle">@style/header_style</item> in your main activity style

`  <style name="header_style">
     <item name="android:layout_marginStart">5dp</item>
    <item name="android:textSize">18sp</item>
    <item name="android:textColor">@color/white</item>
</style>`
Gattis answered 25/1, 2022 at 13:54 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.