使用带有 GuidedStepSupportFragment 的自定义 XML 布局进行智能电视 UI 设计
Posted
技术标签:
【中文标题】使用带有 GuidedStepSupportFragment 的自定义 XML 布局进行智能电视 UI 设计【英文标题】:Use Custom XML Layout with GuidedStepSupportFragment For Smart TV UI Design 【发布时间】:2020-10-24 19:40:46 【问题描述】:如何使用带有 GuidedStepSupportFragment
的自定义 xml 布局文件和leanback 库。
我需要在左右两侧使用自定义视图并进行一些操作。我怎样才能做到这一点?我是智能电视开发的新手。
我需要一些这种更个性化的设计:
【问题讨论】:
【参考方案1】:GuidedStepFragment
由两部分组成,Guidance
(左侧)和Actions
(右侧)。您可以通过在相应的Stylist
中覆盖onProvideLayoutId
来为它们提供布局。
例如,如果您想更改Guidance
,您可以使用以下代码:
@Override
public GuidanceStylist onCreateGuidanceStylist()
return new GuidanceStylist()
@Override
public int onProvideLayoutId()
// return your cutom layout
return R.layout.layout_custom_guidance;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Guidance guidance)
View guidanceView = super.onCreateView(inflater, container, guidance);
// You can access Views here
return guidanceView;
;
Actions
部分由多个 GuidedAction
项目组成,您可以为每个项目提供类似的布局:
@Override
public GuidedActionsStylist onCreateActionsStylist()
return new GuidedActionsStylist()
@Override
public int onProvideItemLayoutId()
// return your custom layout for each GuidedAction item
return R.layout.layout_custom_action_item;
@Override
public ViewHolder onCreateViewHolder(ViewGroup parent)
ViewHolder viewHolder = super.onCreateViewHolder(parent);
// Access Views here
return viewHolder;
;
对于您特定的Actions
一侧,您可以插入一个带有您预期布局的Action
。
【讨论】:
如果我们想完全避免 GuidedActions 怎么办?有可能吗? @carrasc0 我不确定。您可以使用自定义布局添加一项操作。以上是关于使用带有 GuidedStepSupportFragment 的自定义 XML 布局进行智能电视 UI 设计的主要内容,如果未能解决你的问题,请参考以下文章
如何使用带有或不带有 Appium 的 Robot Framework 集成 WinAppDriver?
使用带有 ajax Rest 调用的 Spring CSRF 和带有 Thymeleaf 的 HTML 页面
如何在带有 React 的 Typescript/JSX 中使用带有箭头函数的泛型?
优化数据库有啥更好的方法:使用带有不同过滤器的一堆存储过程,还是使用带有 if 条件的单个存储过程?