windowInsetsEndWidth
Compose Modifier
Common
fun Modifier.windowInsetsEndWidth(insets: WindowInsets) =
if (ComposeFoundationLayoutFlags.isWindowInsetsModifierLocalNodeImplementationEnabled)
this then
DerivedWidthModifierElement(
insets,
debugInspectorInfo {
name = "insetsEndWidth"
properties["insets"] = insets
},
endCalc,
)
else
this.then(
DerivedWidthModifier(
insets,
debugInspectorInfo {
name = "insetsEndWidth"
properties["insets"] = insets
},
endCalc,
)
)
Sets the width to that of insets at the end of the screen,
using either left or right, depending on the
LayoutDirection.
When used, the WindowInsets will respect the consumed insets from
windowInsetsPadding and consumeWindowInsets, but won't consume any insets.
Code Examples
insetsEndWidthSample
fun insetsEndWidthSample() {
class SampleActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
WindowCompat.setDecorFitsSystemWindows(window, false)
super.onCreate(savedInstanceState)
setContent {
Box(Modifier.fillMaxSize()) {
// Background for navigation bar at the end
Box(
Modifier.windowInsetsEndWidth(WindowInsets.navigationBars)
.fillMaxHeight()
.align(Alignment.CenterEnd)
.background(Color.Red)
)
// app content
}
}
}
}
}
