Template version: v0.2.2
react-native-input-scroll-view
[!TIP] GitHub address
Find the matching version information in the release address of a third-party library: @react-native-oh-tpl/react-native-input-scroll-view Releases.For older versions that are not published to npm, please refer to the installation guide to install the tgz package.
Go to the project directory and execute the following instruction:
npm install @react-native-oh-tpl/react-native-input-scroll-view
yarn add @react-native-oh-tpl/react-native-input-scroll-view
The following code shows the basic use scenario of the repository:
[!WARNING] The name of the imported repository remains unchanged.
import React, { useState } from 'react';
import { StyleSheet, TextInput, View, TouchableOpacity, Text } from 'react-native';
import InputScrollView from 'react-native-input-scroll-view';
const keyboardOffsetInput = () => {
const [text, setText] = useState('');
return (
<View style={styles.container}>
<InputScrollView keyboardOffset={100}>
<View style={styles.placeholder} />
<TextInput style={styles.input}
value={text}
multiline
onChangeText={setText}
/>
</InputScrollView>
</View>
);
}
const styles = StyleSheet.create({
container: {
backgroundColor: '#EEE',
},
placeholder: {
height: 400,
justifyContent: 'center',
alignItems: 'center',
},
input: {
margin: 20,
paddingVertical: 10,
paddingHorizontal: 20,
borderColor: 'gray',
borderWidth: 1,
backgroundColor: '#FFF',
},
});
export default keyboardOffsetInput;
To use this repository, you need to use the correct React-Native and RNOH versions. In addition, you need to use DevEco Studio and the ROM on your phone.
Check the release version information in the release address of the third-party library: @react-native-oh-tpl/react-native-input-scroll-view Releases
[!TIP] The Platform column indicates the platform where the properties are supported in the original third-party library.
[!TIP] If the value of HarmonyOS Support is yes, it means that the HarmonyOS platform supports this property; no means the opposite; partially means some capabilities of this property are supported. The usage method is the same on different platforms and the effect is the same as that of iOS or Android.
Name | Description | Type | Required | Default | Platform | HarmonyOS Support |
---|---|---|---|---|---|---|
topOffset | InputScrollView 相对于窗口顶部的偏移量。当屏幕包含 TopBar 时,通常设置为 TopBar 的高度。如果未明确设置,程序会自动判断,但是可能会引起问题。 issues#43。 |
number | false | undefined | iOS/Android | yes |
keyboardOffset | 当自动调整时,光标相对于键盘顶部的偏移量 | number | false | 40 | iOS/Android | yes |
multilineInputStyle | 如果你的多行输入框有特定的样式,那么为了光标能够精准调整到键盘上方,应该将多行文本的样式也设置在这里,主要包含 fontSize 、fontFamily 、lineHeight 等会影响到光标位置的样式属性。注意,不要包含 width 和 height 。 |
Style | false | null | iOS/Android | yes |
useAnimatedScrollView | 用 Animated.ScrollView 组件替换 ScrollView 组件。 |
bool | false | false | iOS/Android | yes |
supportHardwareKeyboard | beta 如果你的设备不使用软键盘,可以尝试使用此参数解决问题。 issues#69 |
bool | false | false | iOS/Android | yes |
keyboardAvoidingViewProps | KeyboardAvoidingView 组件的 Props。详细请查阅: https://facebook.github.io/react-native/docs/keyboardavoidingview |
props | false | null | iOS/Android | yes |
...ScrollView.props | 继承 ScrollView 组件的所有属性。详细请查阅: https://facebook.github.io/react-native/docs/scrollview.html |
props | false | iOS/Android | yes |
This project is licensed under The MIT License (MIT).
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。