我正在使用React Native和Native Base库.当键盘打开时,我需要一个onPress事件来触发Native Base的ListItem(相当于TouchableOpacity).
我现在必须单击一次关闭键盘,然后我可以按ListItem.
下面的内容标记等同于ScrollableView:
<Content keyboardShouldPersistTaps='always' keyboardDismissMode='on-drag'>
<List>
<ListItem style={styles.inspectionsItemDivider} itemDivider>
<TextInput
autoFocus={true}
ref={(input) => { this.titleSearch = input }}
placeholder='Start typing...'
multiline={true}
onChangeText={this.setSearchText.bind(this)}
value={this.getSearchValue()}/>
</ListItem>
<View style={styles.searchContainer}>
<Text style={styles.recentText}>Recommended Descriptions</Text>
<List dataArray={this.state.searchedDescriptions}
renderRow={(description) =>
<ListItem button onPress={() => this.setInformationDescription(description)}>
<Text>{description}</Text>
</ListItem>
</List>
</View>
</List>
</Content>
Run Code Online (Sandbox Code Playgroud) 我正在使用React Native的Keyboard Avoiding View,行为设置为padding(在Android上测试).
我的屏幕上有多个TextInputs.当我单击最终的TextInput时,键盘会覆盖它.我现在能够向下滚动,因为从KeyboardAvoidingView添加了填充,但它是理想的自动滚动焦点.
<Content>
<KeyboardAvoidingView behavior='padding'>
<TextInput placeholder='Example 1' />
<TextInput placeholder='Example 2' />
<TextInput placeholder='Example 3' />
<TextInput placeholder='Example 4' />
<TextInput placeholder='Example 5' />
<TextInput placeholder='Example 6' />
<TextInput placeholder='Example 7' />
</KeyboardAvoidingView>
</Content>
Run Code Online (Sandbox Code Playgroud) 是否可以向矩形元素添加背景填充?我正在使用 rect 元素来创建条形图。每个 rect 元素都有一个宽度和填充集。我想用颜色填充剩余的宽度。
See here: http://codepen.io/jesouhaite08/pen/fhvzA
Run Code Online (Sandbox Code Playgroud)
谢谢!
我使用图像作为我的一个页面的背景.我想在图像上添加一个不透明度的backgroundColor.我不确定如何使用React Native实现这一目标.
render() {
return (
<Image source={require('./assets/climbing_mountain.jpeg')} style={styles.container}>
<Text>Hello</Text>
</Image>
)
}
const styles = StyleSheet.create({
container: {
flex: 1,
width: null,
height: null,
}
Run Code Online (Sandbox Code Playgroud)
以下是我在网页上实现这一目标的方法:如何在CSS中对图像进行叠加?
我正在使用React Native的Modal组件。当模态可见时,我想专注于TextInput和显示键盘。
任何想法如何做到这一点?