How to customise Header Item of Row in android leanback library?
Asked Answered
C

2

7

enter image description here

I am new in Android TV development.

I use android leanback library for this. Also I I use BrowseSupportFragment and RowsSupportFragmen.

Here I want to customise the HeaderItem shown in the picture.

Specially I want to change its font. I check lots of things but not getting proper solution for this.

Thank You.

Cicisbeo answered 24/9, 2019 at 7:0 Comment(0)
I
2

If you use BrowseSupportFragment you can use method setHeaderPresenterSelector() and register own presenter for headers. It should inherard from RowHeaderPresenter

If you want to override all header at once then you can create file res/values/layout/lb_row_header.xml and redefine layout for default header presenter.

Invigorate answered 29/9, 2019 at 6:10 Comment(7)
I think setHeaderPresenterSelector is for left side drawer header not for this one which i mention in the question.Cicisbeo
Here I am Using RowsSupportFragmentCicisbeo
Yes setHeaderPresenterSelector is for left side drawer.Cornflakes
@Cicisbeo i've you got any solution for this, I'm also looking for that solutionCornflakes
@Cornflakes I did lots of r&d about that but not got any solution. Also one thing I see in TV app development, in all cases of TV development apps there is no customisation. Leanback library give lots of functionalities as it is default and less customisation is available in thatCicisbeo
@sohel.eco, I've followed, this link and achieved the text with icon..#46199105 and also in this below URL they told how to change the text font also #41780779 font i didn't try.Cornflakes
Hi Guys, i am new to android leanback, anybody has an idea, that how to stop header(left side) animation in browse fragment ?Swell
P
1

Try this:

 override fun onBindRowViewHolder(holder: RowPresenter.ViewHolder?, item: Any?) {
    super.onBindRowViewHolder(holder, item)
    val textView = holder?.headerViewHolder?.view?.findViewById<RowHeaderView>(R.id.row_header)
    textView?.run {
        setTextColor(Color.WHITE)
        setTextSize(TypedValue.COMPLEX_UNIT_SP, 12.5f)
        isAllCaps = true
        setFontFamily(context, R.font.hind_bold)
    }
 }
Poacher answered 28/7, 2020 at 18:29 Comment(1)
If you enabled non-transitive R classes, use androidx.leanback.R.id.row_headerZymometer

© 2022 - 2024 — McMap. All rights reserved.