Decorator
Decorator copied to clipboard
RTL support for GridLayoutManager
GridSpanMarginDecoration now adds the horizontal margin to the items left and right as full or semi, based on the first, end, or middle position in a row. But in RTL layouts the values that have been used for left and right should be swapped. For instance when we define 16dp as horizontal margin between items, the first position in gridlayout should have margin as below: in LTR -> left=16 , right =8 in RTL -> left = 8, right = 16
Hey @vahid-m
All decorators use specific left/right values instead of start/end. Typically left/right means exactly that, it doesn't change depending on LTR or RTL.
I could add support for start/end instead and add an extra RTL flag that you can get from the LayoutManager.
For now, you can on the declaration site configure those different values yourself by using this method from GridLayoutManager
: https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/LinearLayoutManager#islayoutrtl