答案 0 :(得分:2)
要更改列表行标题样式,您必须使用自定义ListRowPresenter:
public class CustomListRowPresenter extends ListRowPresenter {
public CustomListRowPresenter() {
super();
setHeaderPresenter(new CustomRowHeaderPresenter());
}
}
public class CustomRowHeaderPresenter extends RowHeaderPresenter {
@Override
public Presenter.ViewHolder onCreateViewHolder(ViewGroup parent) {
Presenter.ViewHolder viewHolder = super.onCreateViewHolder(parent);
RowHeaderView rowHeaderView = (RowHeaderView) viewHolder.view;
rowHeaderView.setTypeface(...);
rowHeaderView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, ...);
return viewHolder;
}
}
Haven没有使用BrowseFragment的任何直接经验,但我希望也有某种自定义演示者。
答案 1 :(得分:1)
public class CustomListRowPresenter extends ListRowPresenter {
public CustomListRowPresenter() {
super();
setHeaderPresenter(new CustomRowHeaderPresenter());
}
}
class CustomRowHeaderPresenter extends RowHeaderPresenter {
@Override
public void onBindViewHolder(Presenter.ViewHolder viewHolder, Object item) {
HeaderItem headerItem = item == null ? null : ((Row) item).getHeaderItem();
RowHeaderPresenter.ViewHolder vh = (RowHeaderPresenter.ViewHolder) viewHolder;
TextView title = vh.view.findViewById(R.id.row_header);
if(!TextUtils.isEmpty(headerItem.getName())) {
title.setText(headerItem.getName());
title.setTextColor(ContextCompat.getColor(FiosTVApplication.getAppContext(),
R.color.white));
title.setTypeface(ResourcesCompat.getFont(title.getContext(), R.font.nhaasgroteskdsstd_bold));
title.setTextSize(TypedValue.COMPLEX_UNIT_SP,16);
}
}
}
答案 2 :(得分:0)
设置标题文本颜色的另一种简单方法是覆盖xml中的leanback颜色:
<color name="lb_browse_header_color">#f00</color>
优点/缺点:它为所有标题设置颜色。