Comments (3)
Yeah, this will happen with CoordinatorLayout
. It is very opinionated about inset handling (which is one of the reasons why I wrote Insetter), which makes custom inset handling hard.
You can turn all of that off by setting android:fitsSystemWindows=βfalseβ
on the CoordinatorLayout. Then Insetter should work like on any other view.
from insetter.
Thanks, but unfortunately that doesn't fix it. I set android:fitsSystemWindows="false"
and nothing changed π. I updated my sample with this.
My theory is that the OnApplyWindowInsetsListener
that the CollapsingToolbarLayout
adds is overwriting the work that Insetter is doing. I'm looking through the source now to find out why/how.
from insetter.
Ok, I found a solution.
Turns out the CollapsingToolbarLayout
is preventing the OnApplyWindowInsetsListener
for Views outside the AppBarLayout
from ever being notified. Listeners within the AppBarLayout
were being notified as expected. This looks like a bug within CollapsingToolbarLayout
, probably in CollapsingToolbarLayout.onWindowInsetChanged()
line 295 where it consumes all the window insets instead of returning them.
As a work-around, I modified your applySystemWindows
method to apply the listener to the rootView
:
fun applySystemWindowsWithCollapsingToolbar(
view: View,
applyLeft: Boolean,
applyTop: Boolean,
applyRight: Boolean,
applyBottom: Boolean
) {
view.rootView.doOnApplyWindowInsets { _, insets, padding ->
val left = if (applyLeft) insets.systemWindowInsetLeft else 0
val top = if (applyTop) insets.systemWindowInsetTop else 0
val right = if (applyRight) insets.systemWindowInsetRight else 0
val bottom = if (applyBottom) insets.systemWindowInsetBottom else 0
view.setPadding(
padding.paddings.left + left,
padding.paddings.top + top,
padding.paddings.right + right,
padding.paddings.bottom + bottom
)
}
}
However, this breaks the listeners within the AppBarLayout
. So for now, I have two sets of binding adapters, one from Insetter and a custom set (above) just for this edge case.
from insetter.
Related Issues (20)
- Bug: Custom listener + consuming insets HOT 4
- Request: CONSUME_AUTO support in Kotlin DSL HOT 1
- Not work in Motion Layout
- Attribute layout_marginSystemWindowInsets not work HOT 1
- Insets are not applied on orientation change (screen rotation) HOT 3
- Migration from 0.3.1 to 0.6.0 HOT 2
- Preview on Insetter Constraint Layout does not work HOT 2
- 0.5.0 is not available at jitpack.io anymore HOT 2
- InsetterDsl -> Insetter.CONSUME_AUTO HOT 1
- Issue with animated inset keyboard padding HOT 2
- Request: Remove insets HOT 6
- Ability to adjust applied paddings/margins before applying them to a view HOT 1
- Expose setOnApplyInsetsListener with the InsetterDsl HOT 1
- Is this project deprecated since we have inset support from Androidx now? HOT 3
- Cann't set inset for MaterialToolbar inside CollapsingToolbarLayout HOT 3
- Insets should be applied every time the view is attached to a window
- Keyboard inset padding and NestedScrollView HOT 7
- Render problem [Insetter-widgets] HOT 1
- Issues applying to margins after updating to 0.5.0 HOT 3
- Request: Inset builder to have option to return the actual size HOT 5
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 insetter.