How could I disable edge-to-edge in API 35 so that layer elements is missing in the status bar,
or how to set top margins for elements ( android:layout_marginTop ) below of the status bar?
Height of status bar:
val status_bar_height = (getResources().displayMetrics.density * 24F).toInt()
How to shift all elements of layer in Activity to down?:
not working code in Activity:
mybutton.top = 50
not working code in Layout:
android:layout_marginTop="@*android:dimen/status_bar_height"
2
Answers
Looks like you need windowOptOutEdgeToEdgeEnforcement
Here are a few approaches to achieve what you want:
To disable edge-to-edge and revert to the old behavior in API 35:
2.If you want to keep edge-to-edge but add padding/margin below the status bar, you can use WindowInsets:
3.If you want to add margin programmatically to specific views:
// In your Activity
The reason your original attempts weren’t working:
mybutton.top = 50 – This directly modifies the view’s position property, which doesn’t affect the layout parameters
@*android:dimen/status_bar_height – This is a system resource that’s not directly accessible in this way