Beginning with Android 10 (API level 29), the Android system supports fully gesture-based navigation. There are two things that app developers should do to ensure their apps are compatible with this feature:
- Extend app content from edge to edge.
- Handle conflicting app gestures.
Edge-to-edge app content
To take advantage of the additional screen space made available by the floating navigation bar, you need to configure certain changes in your app.
See Implement edge-to-edge in your app for details.
Update your app to support the predictive back gesture
Android 13 (API level 33) introduces a predictive back gesture for Android devices such as phones, large screens, and foldables. The predictive back gesture is part of a multi-year release; when fully implemented, this feature will let users preview the destination or other result of a back gesture before they fully complete it, allowing them to decide whether to continue or stay in the current view.
See Add support for the predictive back gesture for details.
Handle conflicting app gestures
The gesture navigation model may conflict with gestures that were previously used by app developers. You may need to make adjustments to your app's user interface as a result.
Conflicts with Back gestures
The new system gesture for Back is an inward swipe from either the left or the
right edge of the screen. This may interfere with app navigation elements in
those areas. To maintain functionality of elements on the left and right edges
of the screen, you'll need to opt out of the Back gesture selectively by
indicating to the system which regions need to receive touch input. You can do
this by passing a List<Rect>
to the View.setSystemGestureExclusionRects()
API introduced in Android 10. This method is also available in ViewCompat
as of
androidx.core:core:1.1.0-dev01
.
For example:
Kotlin
var exclusionRects = listOf(rect1, rect2, rect3) fun onLayout( changedCanvas: Boolean, left: Int, top: Int, right: Int, bottom: Int) { // Update rect bounds and the exclusionRects list setSystemGestureExclusionRects(exclusionRects) } fun onDraw(canvas: Canvas) { // Update rect bounds and the exclusionRects list setSystemGestureExclusionRects(exclusionRects) }
Java
List<Rect> exclusionRects; public void onLayout( boolean changedCanvas, int left, int top, int right, int bottom) { // Update rect bounds and the exclusionRects list setSystemGestureExclusionRects(exclusionRects); } public void onDraw(Canvas canvas) { // Update rect bounds and the exclusionRects list setSystemGestureExclusionRects(exclusionRects); }
Conflicts with Home/Quick Switch gestures
The new system gestures for Home and Quick Switch both involve swipes at the bottom of the screen in the space previously occupied by the nav bar. Apps cannot opt out of these gestures, as they can with the Back gesture.
To mitigate this problem, Android 10 introduces the
WindowInsets.getMandatorySystemGestureInsets()
API, which informs apps of the touch recognition thresholds.
Games and other non-View apps
Games and other apps that don't have a view hierarchy often require the user to
swipe near the system gesture areas. In those cases, games can use
Window.setSystemGestureExclusionRects()
to exclude areas that overlap with areas reserved for system gestures. Games
should make sure to only exclude these areas when necessary, such as during
gameplay.
If a game requires the user to swipe near the home gesture area, the app can request to be laid out in immersive mode. This disables the system gestures while the user is interacting with the game, but allows the user to re-enable the system gestures by swiping from the bottom of the screen.
Additional resources
To learn more about gesture navigation, consult the following additional resources.