13 Star 104 Fork 304

react-native-oh-library/usage-docs

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
react-native-input-scroll-view.md 5.49 KB
一键复制 编辑 原始数据 按行查看 历史

模板版本:v0.2.2

react-native-input-scroll-view

Supported platforms License

[!TIP] Github 地址

安装与使用

请到三方库的 Releases 发布地址查看配套的版本信息:@react-native-oh-tpl/react-native-input-scroll-view Releases 。对于未发布到npm的旧版本,请参考安装指南安装tgz包。

进入到工程目录并输入以下命令:

npm

npm install @react-native-oh-tpl/react-native-input-scroll-view

yarn

yarn add @react-native-oh-tpl/react-native-input-scroll-view

下面的代码展示了这个库的基本使用场景:

[!WARNING] 使用时 import 的库名不变。

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;

约束与限制

兼容性

要使用此库,需要使用正确的 React-Native 和 RNOH 版本。另外,还需要使用配套的 DevEco Studio 和 手机 ROM。

请到三方库相应的 Releases 发布地址查看 Release 配套的版本信息:@react-native-oh-tpl/react-native-input-scroll-view Releases

属性

[!TIP] "Platform"列表示该属性在原三方库上支持的平台。

[!TIP] "HarmonyOS Support"列为 yes 表示 HarmonyOS 平台支持该属性;no 则表示不支持;partially 表示部分支持。使用方法跨平台一致,效果对标 iOS 或 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 如果你的多行输入框有特定的样式,那么为了光标能够精准调整到键盘上方,应该将多行文本的样式也设置在这里,主要包含 fontSizefontFamilylineHeight 等会影响到光标位置的样式属性。注意,不要包含 widthheight 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

遗留问题

其他

开源协议

本项目基于 The MIT License (MIT) ,请自由地享受和参与开源。

Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/react-native-oh-library/usage-docs.git
git@gitee.com:react-native-oh-library/usage-docs.git
react-native-oh-library
usage-docs
usage-docs
master

搜索帮助