小编Ish*_*san的帖子

KeyboardDidShow/Hide 事件在具有 adjustmentResize 设置的 Android 上不起作用

我正在尝试使用 捕获 Android 上键盘显示/隐藏事件的事件React Native。我陷入了死胡同。

这是我的清单设置:

<activity
    android:launchMode="singleTop"
    android:name=".MainActivity"
    android:screenOrientation="portrait"
    android:label="@string/app_name"
    android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
    android:windowSoftInputMode="adjustResize">
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
        <action android:name="android.intent.action.DOWNLOAD_COMPLETE"/>
    </intent-filter>
</activity>
Run Code Online (Sandbox Code Playgroud)

这是我的 RN 组件:

import React, {Component} from 'react';
import {
    View,Keyboard
} from 'react-native';

export default class KeyboardAwareComponent extends Component {
    componentDidMount() {
        Keyboard.addListener("keyboardDidShow",()=>{
            console.log("Show event");
        })
    }

    render() {
        return <View />
    }
}
Run Code Online (Sandbox Code Playgroud)

提前非常感谢您:)

android react-native

5
推荐指数
1
解决办法
4501
查看次数

标签 统计

android ×1

react-native ×1