Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

So I am doing an Android TV app which is basically a main screen full of Tv Series and movies like any other traditional video streaming app. For that what I did was to simple use RowsSupportFragment with multiple rows and multiple presenters as I have to change the UI per row. For example: first row is the Billboards row, second one the continue watching list and then all the common rows with plain images

For this particular Billboards row I need to mimic the old carousel behaviour in this two points:

  1. I need to center all the items in the middle of the screen, the only big problem here are the first and last item as it looks more on the edges of the screen. I need to find a way to center those items in the middle.
  2. I need to loop all the row in a way like if I am at the last item if I pressed the DPAD Right it needs to go back to the first element and if I am in the first item and press the DPAD Left i have to go to the last item but like an infinite scroll.

Not sure if it is doable to do it using the Leanback library in Android TV as I am really lost with this. I was able to get the gridView per row doing this:

private fun getBillboardGridView(): HorizontalGridView? {
    val billboardRowPosition = 0
    val billboardContainer = verticalGridView?.get(billboardRowPosition )
    return ((billboardContainer as? ViewGroup)?.get(1) as? ListRowView)?.gridView
}

and do something like:

private fun someTest(): HorizontalGridView? {
    getBillboardGridView()?.smoothScrollToPosition(anyPosition)
}

But not able to do anything with this HorizontalGridView...

EDIT: For Point 1 I was able to achieve it by using:

gridView?.windowAlignment = BaseGridView.WINDOW_ALIGN_NO_EDGE
gridView?.windowAlignmentOffsetPercent = 25f

Thanks in advance for your help

question from:https://stackoverflow.com/questions/65617745/android-tv-rowssupportfragment-center-first-and-last-item-and-infinite-scroll

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
565 views
Welcome To Ask or Share your Answers For Others

1 Answer

Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...