Element overflow hidden in React-Native Android

后端 未结 6 1729
长情又很酷
长情又很酷 2021-01-02 01:15

I have an app here where I need to put the logo in the navbar. That need to overflow the scene layout. Work well in Ios with no problem but in android seem like he not worki

相关标签:
6条回答
  • 2021-01-02 01:36

    This is as pretty epic known issue.

    • Github issue from 2015
      overflow:hidden in React-Native Android
    • React Native Known Issus page
      The overflow style property defaults to hidden and cannot be changed on Android
    • Top trending feature request on the official React Native request board.
      Feature Requests - React Native

    Upvote here to bring the issue more attention.

    0 讨论(0)
  • 2021-01-02 01:37

    You can use the react-native-view-overflow native module by Sibelius Seraphini.

    Also, it seems this might be supported out of the box by React Native starting with version 0.57 according to this commit.

    0 讨论(0)
  • 2021-01-02 01:41

    This is a workaround I've been using since overflow: visible is not working correctly on Android.

    https://medium.com/@jaredgoertzen/react-native-android-doesnt-render-overflow-styles-95e69154ebed

    0 讨论(0)
  • 2021-01-02 01:45

    I had the similar problem and I found this amazing article on medium.com. https://medium.com/entria/solving-view-overflow-in-android-reactnative-f961752a75cd

    According to the article, you can use react-native-view'overflow library (a bridging header written to support the overflow in react-native android.

    All you need to do is wrap the overflowcomponent in the <ViewOverflow>. Hope this helps!

    0 讨论(0)
  • 2021-01-02 01:46

    In Android you cannot draw outside of the component's boundaries, which is a very annoying thing. I usually do the following as a workaround: Wrap your component in a new <View> that wraps both the former container and the overflowing data. Set the view backgroundColor to 'transparent' so that it is invisible, and the pointerEvents prop to 'box-none', so that events get propagated to children. The dimensions of the view should be those of the former top component plus the overflow (in your case, it is just the height), but I think this should also work with Flexbox nicely in some circumstances.

    0 讨论(0)
  • 2021-01-02 01:52

    Following up on martinarroyo's answer. Unfortunately he's right, currently there's no real better way, however, react-native 0.41 (not stable yet) promises to add android support for overflow: visible which is great news, because the workaround isn't all that fun...

    0 讨论(0)
提交回复
热议问题