-
Notifications
You must be signed in to change notification settings - Fork 130
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Android SDK] Revisit activities to see if landscape 3 button navigation handled well #13464
Changes from all commits
b7a1587
3e4f4a6
26ae6d9
a190860
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,8 @@ import android.view.animation.Transformation | |
import android.widget.LinearLayout.LayoutParams | ||
import androidx.constraintlayout.widget.ConstraintLayout | ||
import androidx.constraintlayout.widget.Group | ||
import androidx.core.view.ViewCompat | ||
import androidx.core.view.WindowInsetsCompat | ||
import androidx.core.view.children | ||
import androidx.core.view.isVisible | ||
import androidx.core.view.updateLayoutParams | ||
|
@@ -182,3 +184,19 @@ fun View.scrollStartEvents(): Flow<Unit> { | |
.filter { it == MotionEvent.ACTION_MOVE } | ||
.map { } | ||
} | ||
|
||
fun View.edgeToEdgeHandlingForNavigationBar() { | ||
ViewCompat.setOnApplyWindowInsetsListener(this) { v, insets -> | ||
val systemInsets = insets.getInsets(WindowInsetsCompat.Type.systemBars()) | ||
v.setPadding(systemInsets.left, 0, systemInsets.right, systemInsets.bottom) | ||
insets | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We are using this extension function on the root views. I wonder if we should return From the docs: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unfortunately, we can not do that because then the components that automatically support the edge-to-edge won't apply insets, e.g. in HelpActivity: It's all quite hacky and we should just slowly migrate to Material 3 components and/or compose (also with material 3 components) then it'll be working out of the box |
||
} | ||
} | ||
|
||
fun View.edgeToEdgeHandlingForNavigationAndStatusBar() { | ||
ViewCompat.setOnApplyWindowInsetsListener(this) { v, insets -> | ||
val systemInsets = insets.getInsets(WindowInsetsCompat.Type.systemBars()) | ||
v.setPadding(systemInsets.left, systemInsets.top, systemInsets.right, systemInsets.bottom) | ||
insets | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!