chrisbanes / insetter

Insetter is a library to help apps handle WindowInsets more easily
https://chrisbanes.github.io/insetter
Apache License 2.0
1.13k stars 42 forks source link

Issues applying to margins after updating to 0.5.0 #98

Closed nonproto closed 3 years ago

nonproto commented 3 years ago

Upgraded to the 0.5.0 from 0.3.1

Code was this

   recycler.applySystemWindowInsetsToMargin(top = true)
  recycler.applySystemGestureInsetsToPadding(bottom = true)

and is now this

recycler.applyInsetter {
                type(systemGestures = true) {
                    padding(bottom = true)
                }
                type(statusBars = true) {
                    margin(top = true)
                }
            }

I have to apply the statusbars to margin top or else it fails

View's LayoutParams do not extend MarginLayoutParams errors since updating java.lang.IllegalArgumentException: Margin window insets handling requested but View's LayoutParams do not extend MarginLayoutParams

chrisbanes commented 3 years ago

Sounds like the same issue as #79. Is the parent of recycler a ConstraintLayout? If so, what version are you using?

nonproto commented 3 years ago
 const val constraintLayout = "androidx.constraintlayout:constraintlayout:2.0.4"
 const val coordinatorLayout = "androidx.coordinatorlayout:coordinatorlayout:1.1.0"
const val swipeRefresh = "androidx.swiperefreshlayout:swiperefreshlayout:1.1.0"

the fragment recycler's parent is a swiperefreshlayout inside of the coordinatorlayout

This view is placed inside a standard FragmentContainerView when the fragment is attached

chrisbanes commented 3 years ago

Ah, well there's the issue: SwipeRefreshLayout doesn't support/use MarginLayoutParams so there's no way to add margin. This would happen the same with older versions of the library too.

If you need to use margin, I'd wrap the RecyclerView in a FrameLayout or similar.