HarmonyOS RN上面TextInput输入框组件弹出的软键盘会覆盖UI?

组件 :import {TextInput} from "react-native";

点击输入框弹窗软键盘,如果TextInput在底部会被覆盖住,请问怎么设置不覆盖

import React from "react";
import { View, TextInput, StyleSheet } from "react-native";

export default function TextInputExample() {
  return (
    <View>
      <TextInput
  style={styles.intextInputStyle}
  value="777"
  onChangeText={(text) => {

  }}
underlineColorAndroid="transparent"
autoFocus={true}
keyboardType="numeric"
  />

  </View>
);
}

const styles = StyleSheet.create({
  inputItem: {
    lineHeight: 20,
    width: 80,
    textAlign: "center",
    height: 40,
  },
  intextInputStyle: {
    marginTop: 570,
    height: 40,
    fontSize: 25,
    marginHorizontal:50,
    color: '#3C3834',
    backgroundColor: "yellow",
  },

});
阅读 457
1 个回答

修改了您的demo,您看一下能否满足您的需求:

import React, { useEffect, useState } from "react";
import { View, TextInput, StyleSheet,KeyboardAvoidingView } from "react-native";

const MyComponent=()=>{

  return(
    <KeyboardAvoidingView style={styles.container} behavior='position'>
    <View style={{}}>
  <TextInput value='777' style={styles.intextInputStyle}
onChangeText={(text) => {

}}
underlineColorAndroid="transparent"
autoFocus={true}
keyboardType="numeric"
  />
  </View>
  </KeyboardAvoidingView>
)

}
const styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: 'center',
    marginTop: 570,
  },
  inputItem: {
    lineHeight: 20,
    width: 80,
    textAlign: "center",
    height: 40,
  },
  intextInputStyle: {
    // marginTop: 570,
    height: 40,
    fontSize: 25,
    marginHorizontal:50,
    color: '#3C3834',
    backgroundColor: "yellow",
  },
});

export default MyComponent