该应用程序的结构相当简单:底部有一个搜索栏、一个 ListView 和 react-native-tabs。问题:如果我点击 Android 上的搜索栏,它会将整个应用程序向上推,所以我会直接在键盘上看到选项卡。但是在 iOS 上,键盘覆盖了整个应用程序,没有向上推任何东西。有什么办法可以控制吗?
如果问题不清楚,我很乐意分享代码/屏幕截图。
谢谢
编辑:
<View style={{flex:1, backgroundColor:'#f2f2f2'}}>
<ListView
dataSource={this.state.dataSource}
renderRow={this.renderSearchResults.bind(this)}
style={styles.listView}/>
<KeyboardAvoidingView
style={styles.addQuestionBar}
behavior={'position'}>
<Text>
Don't see your question?
</Text>
<TouchableOpacity>
<Text>
Add it
</Text>
</TouchableOpacity>
</KeyboardAvoidingView>
</View>
最佳答案
套装android:windowSoftInputMode="adjustPan"
在您的 list 文件中,它将按您的预期工作。
例如。
<application
android:name=".MainApplication"
android:allowBackup="true"
...
<activity
android:name=".MainActivity"
android:label="@string/app_name"
...
android:windowSoftInputMode="adjustPan">
...
</activity>
...
</application>
关于React-native:如何控制键盘向上推,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39344140/