android-tv Changing text color and font of browse fragment rows header

前端 未结 3 708
南旧
南旧 2020-12-10 14:22

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.

3条回答
  •  旧时难觅i
    2020-12-10 15:02

    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:

    
    
    
    
    
    
    
    

    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()
    }
    

提交回复
热议问题