gpt4 book ai didi

How do I align text to the left of my Textinput in react Native?(如何在Reaction Native中将文本与文本输入的左侧对齐?)

转载 作者:bug小助手 更新时间:2023-10-25 10:59:01 26 4
gpt4 key购买 nike



I am working on the UI to my login screen. I have tried wrapping the elements differently, someone suggested using Multi-Line I tried that as well.

我正在工作的用户界面,我的登录屏幕。我试着用不同的方式包装元素,有人建议使用多行,我也试过了。


With standard React/JS / css /html I have no issues doing this. But I cannot seem to figure this one out. I try not to ask for help and figure it out on my own to learn but I have been stuck for around 3 hours and I really want to move on.

使用标准的reaction/js/css/html,我可以做到这一点。但我似乎想不出这一点。我试着不寻求帮助,自己想办法去学习,但我已经被困了大约3个小时,我真的想继续前进。


Here is my component for my LoginPageUI:

以下是我的LoginPageUI组件:


export const LoginPageUI = () => {
const [userName, setUserName] = useState("")
const [password, setPassword] = useState("")

return (
<>
<SafeAreaView>
<View style={LoginUIStyles.input}>
<Text style={LoginUIStyles.outerText}>UserName</Text>
<TextInput
multiline={true}
style={LoginUIStyles.inputField}
placeholder="Enter Your UserName"
onChangeText={(text) => setUserName(text)}
value={userName}
></TextInput>
</View>
<TextInput
style={LoginUIStyles.input}
placeholder="Password"
onChangeText={(text) => setPassword(text)}
value={password}
></TextInput>
</SafeAreaView>
</>
);

Here is my style.

这就是我的风格。


export const LoginUIStyles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: "#fff",
justifyContent: "center",
alignItems: "center",
},
inputContainer: {
width: "80%",
},
input: {
flexDirection: "row", // Place text and input side by side
alignItems: "center", // Center items vertically
height: 40,
borderColor: "gray",
borderWidth: 1,
borderRadius: 5,
paddingHorizontal: 10,
marginBottom: 20,
},
outerText: {
flex: 1,
},
inputField: {
flex: 3,
},
});```


I attached a photo of what it looks like currently. I was able to get it to go left in the textInput, however I can't seem to get it outside of the textInput and beside it.




wrapping and moving elements,

multiLine,

using the React-Native Docs for support.


更多回答
优秀答案推荐

Actually, your text has already been aligned to the left-hand side of your TextInput. So, what is causing the appearance of that text to be still within the borders of the TextInput component is due to the css properties of LoginUIStyles.input.

实际上,您的文本已经与TextInput的左侧对齐了。因此,导致该文本的外观仍然在TextInput组件的边界内的原因是LoginUIStyles.input的css属性。


It is noticed that you have housed the Text component and the TextInput component under one View component. If you move its css border properties over to LoginUIStyles.inputField from LoginUIStyles.input, that text should now appear to be outside of the TextInput component like this:

请注意,您已经将Text组件和TextInput组件放在一个View组件下。如果将其CSS边框属性从LoginUIStyles.input移到LoginUIStyles.inputfield,则该文本现在应该显示在TextInput组件之外,如下所示:


this


更多回答

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com