简体   繁体   English

反应本机键盘事件不适用于android:windowSoftInputMode =“ adjustNothing”

[英]React Native keyboard events not working with android:windowSoftInputMode=“adjustNothing”

I am trying to adjust only one component of my view when keyboard is shown so i set "adjustNothing" in my android manifest file and I handle the movement of the component with "keyboardDidHide" event listener and with TextInput onFocus . 当显示键盘时,我试图仅调整视图的一个组件,因此我在Android清单文件中设置了“ adjustNothing” ,并使用“ keyboardDidHide”事件监听器和TextInput onFocus处理了组件的移动。 I tried this but I'm not getting anything from the listener when keyboard hides... 我试过了,但是键盘隐藏时我没有从听众那里得到任何东西...

Here is my AnidroidManifest File: 这是我的AnidroidManifest文件:

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

<application
  android:name=".MainApplication"
  android:label="@string/app_name"
  android:icon="@mipmap/ic_launcher"
  android:allowBackup="false"
  android:theme="@style/AppTheme">
  <activity
    android:name=".MainActivity"
    android:label="@string/app_name"
    android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
    android:screenOrientation="portrait"
    android:windowSoftInputMode="adjustNothing">
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
  </activity>
  <activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
</application>

And this is what i want to do when keyboard hides: 这是键盘隐藏时我要执行的操作:

keyboardDidHide() {
this.animateS(false);
}

so it animates back in place. 因此它会恢复原状。

I tried with adjustResize and adjustPan but they move the whole view up and i don't want that. 我尝试使用adjustResizeadjustPan,但是它们将整个视图向上移动,我不希望这样。 the animation is a simple translate up when keyboard is shown and down when did hide event triggers. 动画是显示键盘时向上和向下隐藏事件触发器时的简单转换。

In the docs: 在文档中:

Note that if you set android:windowSoftInputMode to adjustResize or adjustNothing, only keyboardDidShow and keyboardDidHide events will be available on Android https://facebook.github.io/react-native/docs/keyboard 请注意,如果您将android:windowSoftInputMode设置为AdjustResize或AdjustNothing,则只有在Android https://facebook.github.io/react-native/docs/keyboard上可以使用keyboardDidShow和keyboardDidHide事件

Is this a bug with react native or am i doing something wrong, any ideas? 这是本机反应的错误,还是我做错了任何想法?

This is an error in the React Native Documentation. 这是React Native文档中的错误。

As andreicoman11 stated in this reply to a github issue: ... keyboard events are actually not triggered with adjustNothing because of the way it's implemented, and unfortunately there's no way around that ... 正如andreicoman11在对github问题的答复中所指出的那样: ... keyboard events are actually not triggered with adjustNothing because of the way it's implemented, and unfortunately there's no way around that ...

React native failed to document that at https://facebook.github.io/react-native/docs/keyboard React Native无法在https://facebook.github.io/react-native/docs/keyboard上证明这一点

Change the config param "adjustNothing" to "adjustPan" can solve my problem. 将配置参数“ adjustNothing”更改为“ adjustPan”可以解决我的问题。 Only "adjustPan", do not set with "adjustResize". 仅“ adjustPan”,不设置“ adjustResize”。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用android检查android中键盘的可见性和高度:windowSoftInputMode =“adjustNothing” - Check visibility and height of the keyboard in android with android:windowSoftInputMode=“adjustNothing” android:windowSoftInputMode =“ livejust”中的“ adjustNothing”等效项 - android:windowSoftInputMode=“adjustNothing” equivalent in livecode 反应本机android键盘事件 - React native android keyboard events android键盘无法调整/平移android:windowSoftInputMode = - android keyboard not adjust/pan working android:windowSoftInputMode= Android键盘 - android:windowSoftInputMode =“adjustPan” - Android Keyboard - android:windowSoftInputMode=“adjustPan” android scrollview无法正常工作windowSoftInputMode - android scrollview not working windowSoftInputMode Android windowSoftInputMode无法正常工作 - Android windowSoftInputMode not working android:windowSoftInputMode =“adjustPan”不起作用 - android:windowSoftInputMode=“adjustPan” is not working windowSoftInputMode 在 scrollView android 内不起作用 - windowSoftInputMode not working inside scrollView android android:windowSoftInputMode =“adjustResize”无法正常工作 - android:windowSoftInputMode=“adjustResize” is not working as it should be
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM