我正在研究改变Android的输入方法的各个部分,特别是输入坐标.
所需的键/字符是1234567890.-:当选择数字签名和十进制时,我有前12个覆盖,但不能得到:被包括或任何其他可以取代它的角色(完美的是有一把°钥匙).
我现在用输入过滤器编写过滤这些字符:它可以工作,但它不漂亮.我的主要问题是我不能让键盘在数字侧而不是字母侧打开.
我非常感兴趣的另一个选择是修改现有的电话类型键盘以包括我想要的键.它会消除很多混乱并使剩余的键变大,从而使输入更容易.
我正在使用 React Native 构建一个应用程序。问题是,当通过手机设置更改字体大小时,应用程序中的字体大小也会发生变化,即使它们都设置为固定的字体大小。
例如,考虑以下Text字体大小为 12 的元素:
<Text style={{fontSize: 12}}>Hello World</Text>
Run Code Online (Sandbox Code Playgroud)
我发现有一个针对allowFontScaling此问题命名的道具。因此,我转到App.js并添加以下行以禁用整个应用程序中的字体缩放:
Text.defaultProps.allowFontScaling = false;
Run Code Online (Sandbox Code Playgroud)
它工作完美。但是,元素似乎并未实现相同的道具TextInput。当我尝试对 执行相同操作时TextInput,出现以下错误:
undefined 不是对象(评估 '_reactNative.TextInput.defaultProps.allowFontScaling = false')
因此,我可能会为 设定固定的字体大小Text,但不会TextInput。这个问题有什么解决方法吗?我的react-native版本是0.48.4。
提前致谢。
虚拟键盘覆盖了文本输入,我看不到我正在输入的内容。如何避免这种情况?(我尝试使用 KeyboardAwareScrollView 但它仍然覆盖文本输入)。我遇到的另一个问题是关于我的 styles.container 属性 -> justifyContent 和alignItems 的错误 - 它说将它们放在 ScrollView 属性内 - 我不知道如何做到这一点 - 我是 React Native 的新手。
render() {
return (
<KeyboardAwareScrollView>
<View style={styles.container} >
<TextInput
style={styles.input}
underlineColorAndroid="transparent"
placeholder="username"
placeholderTextColor="#00bcd4"
autoCapitalize="none"
secureTextEntry={true}
onChangeText={username => this.setState({ username })}
/>
<View style={styles.btnContainer}>
<TouchableOpacity style={styles.userBtn} onPress={() => this.Login(this.state.email, this.state.password)}>
<Text style={styles.btnTxt}>Login</Text>
</TouchableOpacity>
</View>
</View>
</KeyboardAwareScrollView>
Run Code Online (Sandbox Code Playgroud)
对于 KeyboardAvoidingView 也有同样的事情:
render() {
return (
// <View style={styles.container} >
<KeyboardAvoidingView behavior="padding" style={styles.container}>
<Text style={styles.heading} >Welcome to SelfCare !</Text>
<Image
style={{width: 200, height: 200, …Run Code Online (Sandbox Code Playgroud) android textinput scrollview android-virtual-keyboard react-native
我的 React Native 应用程序中有TextInput组件,当我添加secureEntryText: 'true'密码输入时,我注意到两件事:
1)当我输入密码时,输入密码的左边缘移出输入框的左侧,如下所示:
2)当我取消密码输入焦点时,无论密码有多长,输入的密码末尾都会有一个省略号,如下所示:
有谁知道我如何解决这些问题?
textinput reactjs react-native react-native-text react-native-textinput
我正在尝试创建一个表单,其中写入“其他”选项作为最后一个单选按钮。我尝试过以下变体但没有成功:
<label><input type="radio" name="candidate" value="option1">First Option</label>
<label><input type="radio" name="candidate" value="option2">Second Option</label>
<label><input type="radio" name="candidate" value="other">OTHER</label><input type="text" name="other" value="Write In" />
Run Code Online (Sandbox Code Playgroud)
是否可以有一个带有文本输入的单选按钮,在提交时将其值传递给该单选按钮而不使用 javascript?
好的,我一直在研究 SDL 中的文本输入(如何将击键数据转换为字母并将它们附加到名为 Text 的 std::string 中),并且大多数教程都以这种方式进行了介绍:
//If a key was pressed
if(event->type == SDL_KEYDOWN )
{
//If the key is a lowercase letter
else if( (event->key.keysym.unicode >= (Uint16)'a' ) && (event->key.keysym.unicode <= (Uint16)'z' ) )
{
//Append the character
Text += (char)event->key.keysym.unicode;
}
}
Run Code Online (Sandbox Code Playgroud)
然而,经过一番搜索后,我在 SDL 标头中发现了一条注释,指出 .unicode 已弃用并使用SDL_TextInputEvent/SDL_TextEditingEvent。SDL 文档 wiki 中有一些关于它的参考,但是我找不到任何有关如何使用它的示例。例如,我将如何使用新结构编写上面的代码片段?
当鼠标悬停时,如何使光标成为输入文件或输入文本上的指针?
我尝试过,但当然行不通,
<input type="file" style="cursor: pointer;"/>
Run Code Online (Sandbox Code Playgroud)
或者我必须使用javascrip(jquery)?
编辑:
抱歉我的错误 - 光标确实变成了一个点
<input type="text" style="cursor: pointer;"/>
Run Code Online (Sandbox Code Playgroud)
但不上
<input type="file" style="cursor: pointer;"/>
Run Code Online (Sandbox Code Playgroud)
您可以在 Firefox 上测试此链接,然后您就会明白我的意思。
仅将buttonoffile更改为指针,但未更改input fieldof file。
编辑2:
这是我的 CSS 'hack',
<div id="right-col" style="position:relative; width:76px; height:24px; overflow:hidden; border:1px solid #000;">
<input type="file" style="position:absolute; top:0; right:0; z-index:2;opacity:1; cursor:pointer;"/>
</div>
Run Code Online (Sandbox Code Playgroud) 我是 React Native 的新手,我一直在研究一个搜索栏,它可以在用户输入字段时过滤列表。这是它的样子......
<TextInput style={{width: '100%', textAlign: 'center'}}
ref={(ref) => this.searchInput = ref}
placeholder="Search"
onChangeText={ (text) => this.onChangeText(text)}
value={this.state.search} />
Run Code Online (Sandbox Code Playgroud)
这是我用于此行为的 onChangeText 方法
onChangeText(text) {
var filtered;
this.setState({search: text});
filtered = this.props.data.filter((item) => {
if(item.section) {
return true;
}
return (item.label.toLowerCase().includes(text.toLowerCase()));
});
this.setState({filteredList: filtered});
}
Run Code Online (Sandbox Code Playgroud)
我已将状态设置为保留用户在搜索栏中输入的任何内容,因为它会在渲染时清除。这工作正常,除了每次组件重新渲染时键盘一直关闭(在用户输入/删除的每个字符上)。
为了解决这个问题,我尝试使用像这样的 refs 专注于输入
componentDidUpdate() {
if(this.searchInput) {
this.searchInput.focus();
}
}
Run Code Online (Sandbox Code Playgroud)
但即便如此,键盘还是会时不时地播放打开/关闭动画,并且无法顺利处理输入/删除操作。
为了解决这个问题,我想将 TextInput 移动到一个单独的组件中(只有那个输入字段),然后将该组件添加到我的列表中。但是,我必须不断地将文本数据传回以过滤我的列表,从而增加了更多的复杂性。可能有更简单的解决方案吗?
所以我用我的状态来控制文本输入,但是当我输入一个字符时,我不希望该字符立即显示。正在发生的事情是这样的: 1. 我专注于文本输入 2. 我输入一个字符。3. 字符快速显示在文本输入中。4. 字符很快消失,并且值恢复到状态,因为状态还没有改变。
我想知道如果状态没有改变,我如何才能阻止角色出现。
这是一个简单的例子:
state = {
myValue: 'hello'
}
changedText = value => {
//Nothing here yet
}
...
render(){
return(
<Input
value={this.state.myValue}
keyboardType="numeric"
onChangeText={this.highIntervalDurationChange}
/>
);
}
Run Code Online (Sandbox Code Playgroud)
正如您所看到的,这并不复杂,我只是想找出一种方法,使按下的字符在按下时不会立即出现,因为当前它出现并恢复到状态。(显然,在我弄清楚如何防止默认情况发生后,我将修改状态。)我还尝试将 editable 设置为 false,这使得我根本无法编辑它。谢谢!
我想构建一个多行 TextInput 聊天应用程序,用户可以在按下 Enter 时发送消息。然而,似乎当用户按下 Enter 时,无论如何都会插入新行,这给用户带来了不好的体验。
我已经尝试过如何在react-native中按下回车键时防止换行,但在用户按键盘中的Enter键后,新行仍然存在。我还尝试在触发时修剪文本onChangeText,但似乎新行仍然插入。我知道它在 时有效blurOnSubmit=true,但我想在用户按 Enter 时保持键盘打开。
textinput ×10
react-native ×6
reactjs ×4
android ×2
c++ ×1
css ×1
file ×1
forms ×1
html ×1
input ×1
javascript ×1
jquery ×1
keyboard ×1
onfocus ×1
radio-button ×1
scrollview ×1
sdl ×1
state ×1
textbox ×1