Skip to content
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 FlatList with borderRadius applied does not respect border to clip list items on Android #44671

Closed
CalNicklin opened this issue May 24, 2024 · 3 comments
Labels
Component: FlatList Platform: Android Android applications. Resolution: Fixed A PR that fixes this issue has been merged.

Comments

@CalNicklin
Copy link

CalNicklin commented May 24, 2024

Description

When applying border radius to a FlatList on Android, FlatList style is not respected when clipping child views in the list. Works on iOS, screen recording for comparison.

Applying 'overflow':'hidden' does not fix.

Steps to reproduce

Render this FlatList:
<View style={{ justifyContent: 'center', alignItems: 'center' }}> <FlatList style={{ width: 150, height: 100, backgroundColor: 'gray', borderBottomLeftRadius:95, borderBottomRightRadius:100, borderTopLeftRadius:180, borderTopRightRadius:165, }} data={['1', '2', '3']} contentContainerStyle={{ justifyContent: 'center', alignItems: 'center', }} renderItem={({ item, index }) => { return ( <View key={index} style={{width: 150, height: 50, backgroundColor: 'red'}}> <Text style={{textAlign: 'center'}}>{item}</Text> </View> ) }} numColumns={1} horizontal={true} pagingEnabled={true} decelerationRate={'fast'} showsHorizontalScrollIndicator={false} /> </View>

React Native Version

0.73.8, also tested on 0.74.1

Affected Platforms

Runtime - Android

Output of npx react-native info

System:
  OS: macOS 14.5
  CPU: (16) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
  Memory: 166.17 MB / 32.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 20.11.1
    path: ~/.volta/tools/image/node/20.11.1/bin/node
  Yarn:
    version: 3.6.4
    path: ~/.volta/tools/image/yarn/3.8.0/bin/yarn
  npm:
    version: 10.2.4
    path: ~/.volta/tools/image/node/20.11.1/bin/npm
  Watchman:
    version: 2024.03.18.00
    path: /usr/local/bin/watchman
Managers:
  CocoaPods:
    version: 1.15.2
    path: /usr/local/bin/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 23.5
      - iOS 17.5
      - macOS 14.5
      - tvOS 17.5
      - visionOS 1.2
      - watchOS 10.5
  Android SDK:
    API Levels:
      - "30"
      - "31"
      - "33"
      - "33"
      - "34"
    Build Tools:
      - 30.0.2
      - 30.0.3
      - 31.0.0
      - 33.0.0
      - 33.0.1
      - 33.0.2
      - 34.0.0
      - 34.0.0
    System Images:
      - android-30 | Google APIs Intel x86 Atom
      - android-30 | Google Play Intel x86 Atom
      - android-31 | Google APIs Intel x86_64 Atom
      - android-33 | Android TV Intel x86 Atom
      - android-33 | Google APIs Intel x86_64 Atom
      - android-34 | Google APIs Intel x86_64 Atom
      - android-34 | Google Play Intel x86_64 Atom
    Android NDK: Not Found
IDEs:
  Android Studio: 2023.1 AI-231.9392.1.2311.11076708
  Xcode:
    version: 15.4/15F31d
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: 17.0.9
    path: /usr/bin/javac
  Ruby:
    version: 2.6.10
    path: /usr/bin/ruby
npmPackages:
  "@react-native-community/cli": Not Found
  react:
    installed: 18.2.0
    wanted: 18.2.0
  react-native:
    installed: 0.74.1
    wanted: 0.74.1
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: false
iOS:
  hermesEnabled: true
  newArchEnabled: false

Stacktrace or Logs

No stack trace required

Reproducer

https://github.com/CalNicklin/flatlist-bug-android

Screenshots and Videos

Screen.Recording.2024-05-24.at.15.17.57.mov
@NickGerleman
Copy link
Contributor

NickGerleman commented May 24, 2024

This is known bug where Android only does border clipping to child for View component currently. This will likely be fixed in future version, but workaround could be to wrap list in view, and apply radius to that.

@CalNicklin
Copy link
Author

CalNicklin commented May 27, 2024

Thanks for the thoughts - that does in fact work if I add 'overflow': 'hidden' to the parent view, and can then remove the style prop from the FlatList.

@CalNicklin
Copy link
Author

CalNicklin commented May 27, 2024

@NickGerleman is it also a known Android bug where borderWidth applied to only one side doesn't render correctly? i.e. should be inset and adhere to borderRadius, instead it's offset.

Screenshot 2024-05-27 at 08 00 38

@cortinico cortinico added Resolution: Fixed A PR that fixes this issue has been merged. and removed Needs: Triage 🔍 labels Jun 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: FlatList Platform: Android Android applications. Resolution: Fixed A PR that fixes this issue has been merged.
Projects
None yet
Development

No branches or pull requests

4 participants
@NickGerleman @cortinico @CalNicklin and others