-
Notifications
You must be signed in to change notification settings - Fork 5
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
RN-SafeAreaView #289
Comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
SafeAreaView
组件功能
在设备安全区域内容展示页面内容:
原理
本质是个
View
组件,但会自动添加padding
。SafeAreaView
不是无脑的添加padding
,而是在适当的时候添加padding
:坐标Y === 0
;坐标X === 0
;坐标Y + View高度 >= 设备高度
;坐标X + View宽度 >= 设备宽度
;当
SafeAreaView
四边处于以上4中情况时,则会给边缘添加合适的padding
。具体实现可以参考
react-native-safe-area-view
库_getSafeAreaStyle
方法的实现。使用
包裹整个页面组件
如果只是简单的把页面内容展示安全区域内,可以用
SafeAreaView
+flex: 1
包裹页面组件即可。正如RN官方的[DEMO]:(https://reactnative.dev/docs/safeareaview#example):头部组件
为了实现更好的沉浸式头部组件(Header, Tab等)可以在这些组件内部使用
SafeAreaView
。底部组件
跟头部组件类似,还有些页面底部的组件中可以直接使用
SafeAreaView
。Issues/Concern
SafeAreaView
显示的指定padding
相关属性。ScrollView
内部使用SafeAreaView
时会发生页面抖动。解决方案:contentInsetAdjustmentBehavior="automatic"
参考
SafeAreaView
SafeAreaView
insideScrollView
breaks scrolling #19658The text was updated successfully, but these errors were encountered: