Comments (4)
This library doesn't do anything on item's height but the offset could change only the item's width. Maybe the middle item has a different width from the others and the height you are using is based on the width?
from recycler-view-divider.
Edit: fix wrong number on picture
This is my solution
object : DividerOffsetProvider {
override fun getOffsetFromSize(grid: Grid, divider: Divider, dividerSide: Side, size: Int): Int {
if (divider.isTopDivider || divider.isBottomDivider || divider.isStartDivider || divider.isEndDivider) return size
val gridOrientation = grid.orientation
if (gridOrientation.isVertical && dividerSide == Side.TOP || gridOrientation.isHorizontal && dividerSide == Side.START) return 0
if (gridOrientation.isVertical && dividerSide == Side.BOTTOM || gridOrientation.isHorizontal && dividerSide == Side.END) return size
val sideDividerSize = 16.dp
val cellsCount = grid.lines[divider.originY].cellsCount
if (cellsCount >= 3) {
val fixedSize = (cellsCount - 2) * sideDividerSize
val allocatableSize = size * (cellsCount - 1) - fixedSize
val averageSize = allocatableSize / cellsCount.toFloat()
if (divider.originX == 1 && dividerSide == Side.END
|| divider.originX == cellsCount - 1 && dividerSide == Side.START) {
return averageSize.toInt()
} else {
val middleCellDividerSize = (sideDividerSize + averageSize) / 2
return middleCellDividerSize.toInt()
}
} else {
return size
}
}
}
from recycler-view-divider.
Perfect, you are probably the first one using the new DividerOffsetProvider
API 🥇
from recycler-view-divider.
You can consider passing sideDividerSize
as a argument to the OffsetProvider
, Make the library easier :)
from recycler-view-divider.
Related Issues (20)
- Animate divider
- Expose 'absoluteCellIndex'? HOT 11
- Run tests on Android Q HOT 1
- Update Android 11
- "GridLayoutManager.multipleSpanGrid" It takes too much time with a large data set HOT 4
- visibilityProvider is not working fine with GridLayoutMananger HOT 3
- Grag Item,the space will bigger and bigger HOT 4
- Fix sourceSets deprecation in CoveragePlugin
- Crash: The grid doesn't contain the item at position... HOT 3
- Equal Spacing HOT 2
- How to set float size decoration? HOT 2
- The size of the divider is wrong after notifyItemRemoved() HOT 2
- How to use the SizeProvider HOT 1
- 使用说明可以详细一些么 HOT 2
- Try JaCoCo report aggregation
- Upgrade Releases Hub Plugin to v4.0.0 HOT 1
- Failed to allocate a xxx0 byte allocation with xxx free bytes and 503MB until OOM, HOT 2
- Dependency Dashboard
- GridView
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from recycler-view-divider.