I'm facing an issue subclassing VerticalGridFragment
in my Android TV project: everything works fine but if in one row there are less items then the maximum number of columns, then the items are horizontally aligned starting from the center.
The weird thing is that it happens only if the total number of elements are less then the maximum number of columns. For example, assuming this number is 6, if I have 1 item, it's placed at the center of the row. Instead, if I have 14 items, the 2 items on the third row are placed starting from the left.
Is there a way to align the items in a row to the left
or start
?
Am I doing something wrong?
I've tried in this way but nothing happens, items are aligned starting from the center.
<style name="AppTheme.Widget.Leanback.GridItems.VerticalGridView"
parent="Widget.Leanback.GridItems.VerticalGridView">
<item name="android:gravity">left|start</item>
</style>
And then set it like this in my theme, which extends from Theme.Leanback
:
<item name="itemsVerticalGridStyle">@style/AppTheme.Widget.Leanback.GridItems.VerticalGridView</item>
VerticalGridPresenter
to provide my own layout for theVerticalGridView
where I set the width to bematch_parent
. Now the items are on the left, even if I see more empty space on the right then on left. But it's a minor issue. If you provide an actual answer here below, I'll accept it. Thanks again. – Yet