Skip to main content

KeyboardAvoidingView

该组件将根据键盘高度自动调整其高度、位置或底部填充,以在显示虚拟键盘时保持可见。

¥This component will automatically adjust its height, position, or bottom padding based on the keyboard height to remain visible while the virtual keyboard is displayed.

示例

¥Example


参考

¥Reference

属性

¥Props

视图属性

¥View Props

继承 视图属性

¥Inherits View Props.


behavior

指定如何对键盘的存在做出反应。

¥Specify how to react to the presence of the keyboard.

Android 和 iOS 与此 prop 的交互方式不同。在 iOS 和 Android 上,建议设置 behavior

¥Android and iOS both interact with this prop differently. On both iOS and Android, setting behavior is recommended.

类型
enum('height', 'position', 'padding')

contentContainerStyle

行为为 'position' 时内容容器(View)的样式。

¥The style of the content container (View) when behavior is 'position'.

类型
View 样式

enabled

启用或禁用 KeyboardAvoidingView。

¥Enabled or disabled KeyboardAvoidingView.

类型默认
booleantrue

keyboardVerticalOffset

这是用户屏幕顶部和 React Native 视图之间的距离,在某些用例中可能不为零。

¥This is the distance between the top of the user screen and the react native view, may be non-zero in some use cases.

类型默认
number0