[Android] ScreenFragment wraps content in FrameLayout (clipChildren=true), unlike ScreenStackFragment which uses CoordinatorLayout (clipChildren=false)

Open Beginner friendly
#3,784 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
72/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Quiet
Tech stack
android, kotlin, react-native
Domain
mobile

Research direction

Start in android/src/main/java/com/swmansion/rnscreens/ScreenFragment.kt at the ScreensFrameLayout inner class, then compare its container behavior with ScreensCoordinatorLayout.kt. Verify the Android reproduction with matching tab and stack screens, and confirm that child shadows and other overflow render without clipping after the container behavior is aligned.

Written by the indexing model from the issue text.

Description

area:stack-v4 platform:android

Description

[!NOTE]
This issue was drafted by Claude Code under my supervision.

On Android, screens rendered via ScreenFragment (used by tab and drawer navigators) clip child overflow, including box-shadow and elevation shadows, while screens rendered via ScreenStackFragment (native stack) do not. Identical React Native markup produces different visual results depending on the navigator type.

This is the root cause behind #2669 and #2478. The suggested workaround of wrapping content in <View collapsable={false} style={{ flex: 1 }}> works but shouldn't be necessary.

Root Cause

ScreenFragment and ScreenStackFragment wrap screen content in different native Android containers with different clipChildren defaults:

Fragment Wrapper Extends clipChildren default
ScreenFragment ScreensFrameLayout FrameLayout true
ScreenStackFragment ScreensCoordinatorLayout CoordinatorLayout false

FrameLayout defaults to clipChildren = true, clipping any child content that overflows its bounds. CoordinatorLayout defaults to clipChildren = false (by design, to support FABs, snackbars, etc.), so stack screens don't have this issue.

Relevant code

Reproduction

  1. Create a tab navigator with a screen containing an absolutely positioned circular button with box-shadow (e.g. near the top of the screen)
  2. Create a stack navigator with identical screen content
  3. Compare on Android — the tab screen clips the shadow to a rectangle, the stack screen renders it correctly as a circle following borderRadius

Suggested Fix

Set clipChildren = false on ScreensFrameLayout to match the CoordinatorLayout behavior:

private class ScreensFrameLayout(context: Context) : FrameLayout(context) {
    init {
        clipChildren = false
    }

    override fun clearFocus() {
        if (visibility != INVISIBLE) {
            super.clearFocus()
        }
    }
}

Environment

  • react-native-screens: 4.16.0 (also confirmed still present on main)
  • React Native: 0.81.5 (new architecture / Fabric)
  • Android
  • Expo SDK 54
Dominant language
TypeScript
Stars
3.7k
Forks
714
Avg merge
3d 2h
Merged PRs (30d)
62

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from software-mansion/react-native-screens

All issues in software-mansion/react-native-screens

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.