epoxy icon indicating copy to clipboard operation
epoxy copied to clipboard

spacingBetweenItem incorrect when using GridLayoutManager(..LinearLayoutManager.HORIZONTAL) in Carousel

Open wsmni520 opened this issue 5 years ago • 1 comments
trafficstars

Hi, brother spaces seems incorrect between item when I using GridLayoutManager(..LinearLayoutManager.HORIZONTAL) in Carousel

screenSize : 1080*2560

I build Carousel model in epoxyController like this: hotCityViewCarouselModelBuilder { id("hotCity") for (index in 0 until 9) { itemHotCityHolder { id("hotCityItem $index") listener { Log.d("zf", "click") } cityName("item") } } }

HotCityViewCarousel class code : `@ModelView(autoLayout = ModelView.Size.MATCH_WIDTH_WRAP_HEIGHT) class HotCityViewCarousel constructor(context: Context) : Carousel(context) { private var SPAN_COUNT = 3

override fun getSnapHelperFactory(): Nothing? = null

override fun createLayoutManager(): LayoutManager {
    return GridLayoutManager(context, SPAN_COUNT, LinearLayoutManager.HORIZONTAL, false)
}

override fun getDefaultSpacingBetweenItemsDp(): Int {
    return 50
}

}`

Carousel Item layout : <?xml version="1.0" encoding="utf-8"?> <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="60dp" android:layout_height="60dp"> <TextView android:id="@+id/hotCityNameTv" android:layout_width="match_parent" android:layout_height="wrap_content" android:textSize="16sp" android:background="?attr/selectableItemBackground"/> </FrameLayout>

item position in layout: 0 3 6 1 4 7 2 5 8 here is Carousel and all Items coordinate in the sceen,1dp = 3px getDefaultSpacingBetweenItemsDp() = 50dp coordinate: (1) androidx.recyclerview.widget.RecyclerView [0,300][1080,1590] item0 > FrameLayout [150,450][330,630] item3 > FrameLayout [480,450][660,630] item6 > FrameLayout [810,450][990,630] item1 > FrameLayout [150,855][330,1035] item4 > FrameLayout [480,855][660,1035] item7 > FrameLayout [810,855][990,1035] item2 > FrameLayout [150,1185][330,1365] item5 > FrameLayout [480,1185][660,1365] item8 > FrameLayout [810,1185][990,1365]

we see firstItem-item0 topPadding is (450 - 300) = 150px correct leftPadding is (150 - 0 ) = 150px correct space between item0 and item1 is (855-630)= 225px incorrect space between item1 and item2 is (1185-1035)=150px correct lastItem-item8 bottomPadding (1590-1365) = 225px incorrect scroll to end measure rightPadding (1080 -930)=150px correct

Although I don't often use this scene, I hope the issue will help to epoxy

screenshoot

wsmni520 avatar Jun 19 '20 09:06 wsmni520