垂直列表,例如android电视leanback中的android手机 [英] Vertical list like android phones in android tv leanback

查看:211
本文介绍了垂直列表,例如android电视leanback中的android手机的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创建一个简单的垂直列表(一行中的单列),该列表只能垂直滚动而不是水平滚动.如何使用leanback在android电视上实现此目标?

I want to create a simple vertical list (single column in a row), which is only scrollable vertically not horizontally. How do i achieve this on android tv using leanback ?

请参阅下图,以进一步了解ui要求.

Refer below image for more clarification on ui requirement.

我尝试使用VerticalSupportFragment,但是行项目没有跨过整个宽度,还尝试更改样式和演示者.

I tried using VerticalSupportFragment, but a row item doesn't spans to a full width, tried changing styles and presenter also.

预先感谢,有什么方法可以实现?

Thanks in advance, is there any way to achieve this ?

推荐答案

如果使用VerticalGridSupportFragment,则可以设置以下列数:

If you use a VerticalGridSupportFragment you can set the number of columns like this:

VerticalGridPresenter presenter = new VerticalGridPresenter();
gridPresenter.setNumberOfColumns(1);
setGridPresenter(gridPresenter);

这有效地为您提供了一个垂直列表.然后,您可以在行项目演示器中编辑视图的宽度.例如,如果您希望视图水平填充屏幕,则可以执行以下操作:

This effectively gives you a vertical list. Then you can edit the width of the view in your row item presenter. For example if you want the view to fill the screen horizontally you could do something like:

int height = 42;
int width = getContext().getResources().getDisplayMetrics().widthPixels;
view.setLayoutParams(new LayoutParams(width, height));

这篇关于垂直列表,例如android电视leanback中的android手机的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆