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.
In addition to David's answer.
rowHeaderStyle
applies the style both to menu items in HeaderFragment
and row titles in RowFragment
(these two fragments compose your BrowseFragment
).
If you want their styles (font colors in particular) to be different, you can override BrowseFragment::onCreateHeadersFragment()
and apply specific theme at that point.
1) Add these styles to styles.xml
:
<style name="AppTheme.Leanback.Browse.Row" parent="@style/Theme.Leanback.Browse">
<item name="rowHeaderStyle">@style/AppTheme.Leanback.Row</item>
</style>
<style name="AppTheme.Leanback.Browse.Header" parent="@style/AppTheme.Leanback.Browse.Row">
<item name="rowHeaderStyle">@style/AppTheme.Leanback.Header</item>
</style>
<style name="AppTheme.Leanback.Row" parent="Widget.Leanback.Row.Header">
<item name="android:textColor">@color/font_row</item>
</style>
<style name="AppTheme.Leanback.Header" parent="Widget.Leanback.Row.Header">
<item name="android:textColor">@color/font_header</item>
</style>
2) Apply AppTheme.Leanback.Browse.Row
theme to your activity in manifest.
3) Apply AppTheme.Leanback.Browse.Header
theme to headers in your BrowseFragment
:
// Kotlin snippet
override fun onCreateHeadersFragment() : HeadersFragment {
class CustomHeadersFragment : HeadersFragment() {
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
return super.onCreateView(
inflater.cloneInContext(ContextThemeWrapper(inflater.context, R.style.AppTheme_Leanback_Browse_Header)),
container,
savedInstanceState
)
}
}
return CustomHeadersFragment()
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With