4

As you know in leanback library there is a ListRowPresenter which presents its items via HorizontalGridView. (see its source here) But can we have a Presenter using VerticalGrid?

I want the last row of my BrowseFragment becomes vertically scrollable (with how many rows as it need and fixed column number!) and instead of setNumRows I would write setNumVolumns ...

Is it possible in leanback?


UPDATE 1 : In order to use a presenter in BrowseFragment, it should be a child of RowPresenter. VerticalGridPresenter is not so you can not use it in a browse fragment at all. I am looking for a something like ListRowPresenter which is built using VerticalGridView. (ListRowPresenter uses HorizontalGridView)

Bulat
  • 720
  • 7
  • 15
Saleh
  • 1,819
  • 1
  • 17
  • 44

1 Answers1

3

Yes, there is a presenter called VerticalGridPresenter that exists for this purpose. It has a method public void setNumberOfColumns(int numColumns) to set the number of columns. If this does not suit your needs you will probably have to write a custom presenter.

Breiby
  • 554
  • 5
  • 14
  • In order to use a presenter in browsefragment, it should be a child of RowPresenter. VerticalGridPresenter is not so you can not use it in a browse fragment at all. I am looking for a something like `ListRowPresenter` which is built using VerticalGridView. (ListRowPresenter uses HorizontalGridView) – Saleh Apr 05 '19 at 11:50
  • There is no such thing. A row is horizontal, so anything extending `RowPresenter` will be horizontal in nature. You are trying to fit a column into a row. It's not built for that. You might be able to achieve it by writing a custom `RowPresenter` yourself, but it wouldn't make much sense. An alternative could be to create your own implementation of `BrowseFragment` with support for a grid under the inner `RowsFragment`. Or you could simply put a `VerticalGridFragment` under your `BrowseFragment`. – Breiby Apr 05 '19 at 12:45
  • 1
    It may make sense. Imagine the last row of browsefragment is full of content. so it is better to browse it vertically than horizontally! I was seeking for a written solution in somewhere if any. Anyhow thanks – Saleh Apr 06 '19 at 13:50
  • @Saleh Did you arrive at any solution for this? I am looking for a similar kind of implementation. Your help would be appreciated. – Prahlad V Thej May 06 '21 at 08:23