FlexboxLayoutManager with FlexboxItemDecoration cause item height incorrent
See original GitHub issue- I have searched existing issues and confirmed this is not a duplicate
Issues and steps to reproduce
Expected behavior
i expect the height of every items is the same, and has correct ItemDecoration
Version of the flexbox library
1.0.0
Link to code
-
Result
-
Step 1 set RecyclerView margin
<android.support.v7.widget.RecyclerView
android:id="@+id/list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="113dp"
android:scrollbars="none"
android:layout_marginLeft="30dp"
android:layout_marginRight="30dp"
android:overScrollMode="never"/>
-
Step 2 add two RecyclerView with FlexLayoutManager, ( And all of them using the same code, Only the datasources is diffrent )
-
Step 3 add FlexboxItemDecoration for the two flexBoxRecyclerViews
private fun init() {
if (layoutManager == null ) {
val flexboxLayoutManager = FlexboxLayoutManager(context, FlexDirection.ROW)
layoutManager = flexboxLayoutManager
initDecoration()
isNestedScrollingEnabled = false
}
overScrollMode = View.OVER_SCROLL_NEVER
isHorizontalScrollBarEnabled = false
isVerticalScrollBarEnabled = false
adapter = mAdapter
}
private fun initDecoration() {
val decoration = FlexboxItemDecoration(context)
val drawable = GradientDrawable().apply {
setSize(Utils.dp2px(context, 15f), Utils.dp2px(context, 15f))
}
decoration.setDrawable(drawable)
decoration.setOrientation(FlexboxItemDecoration.BOTH)
addItemDecoration(decoration)
}
the item layout for each
<com.xinpinget.xbox.widget.textview.AwesomeTextView
android:id="@+id/text"
android:layout_width="wrap_content"
android:layout_height="24dp"
android:text='@{item.text}'
android:textSize="12sp"
android:paddingLeft="9dp"
android:paddingRight="9dp"
app:radius="4dp"
android:maxWidth="122dp"
android:singleLine="true"
android:ellipsize="end"
android:gravity="center_vertical"/>
Test by myself
i exchange the datasource with the top and bottom, the bottom also be incorrent, and i dont think is my code bad....
Although solved by add margin for item, but i think add item decoration is the best way, hope your answer, thanks
Issue Analytics
- State:
- Created 5 years ago
- Reactions:6
- Comments:10 (1 by maintainers)
Top Results From Across the Web
RecyclerView items with different heights with ... - Stack Overflow
I want to use a recycleviewer with FlexboxLayoutManager. Every item normally having their own height depending on their content.
Read more >Recyclerview Items With Different Heights With ... - ADocLib
Hi I am using RecyclerView with FlexboxLayoutManager for layoutManager.setFlexDirectionFlexDirection.ROW; RecyclerView height is. Flexboxlayoutmanager With ...
Read more >Flexbox Based Responsive Equal Height Blocks With ...
It provides almost no time gap between initially wrong and correctly laid out layout look. In JavaScript solution case it takes time to...
Read more >Flexbox for Android – Creating a CenterFlowAdapter
FlexboxLayout and FlexboxLayoutManager are included; both are very ... here isn't just a grid layout that will center the last row of items....
Read more >Keep the Footer at the Bottom: Flexbox vs. Grid
This method relied on setting an explicit footer height, ... one weird trick will cause the margin to fill any space between the...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Any plan to fix this issue? it still exists in 2.0.1
I am experiencing a similar issue as well. Seems related to #246 , but that was supposedly fixed.
I’m using my own drawable to achieve custom padding:
and adding the decoration to my RecyclerView(s):
For certain content that comes very close to filling the entire row width, the wrapping is wrong:
If I adjust the padding slightly so it doesn’t come as close to full row width, the wrapping works as expected: