- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试使用 React Native
在 Android 上捕获键盘显示/隐藏事件。我陷入了死胡同。
这是我的 list 设置:
<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>
这是我的 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 />
}
}
非常感谢您提前:)
最佳答案
以下是直接来自文档的一些事件。
keyboardWillShow
键盘显示
键盘会隐藏
键盘隐藏
keyboardWillChangeFrame
keyboardDidChangeFrame
import React, { Component } from 'react';
import { Keyboard, TextInput } from 'react-native';
class Example extends Component {
componentWillMount () {
this.keyboardDidShowListener = Keyboard.addListener('keyboardDidShow', this._keyboardDidShow);
this.keyboardDidHideListener = Keyboard.addListener('keyboardDidHide', this._keyboardDidHide);
}
componentWillUnmount () {
this.keyboardDidShowListener.remove();
this.keyboardDidHideListener.remove();
}
_keyboardDidShow () {
alert('Keyboard Shown');
}
_keyboardDidHide () {
alert('Keyboard Hidden');
}
render() {
return (
<TextInput
onSubmitEditing={Keyboard.dismiss}
/>
);
}
}
关于android - KeyboardDidShow/Hide 事件在具有 adjustResize 设置的 Android 上不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48026028/
我正在努力获得一个小的 EditText 以及与屏幕底部或软件键盘底部对齐的两个按钮。基本上我的问题是每次我打开我的 Activity (标记为 adjustResize | stateAlwaysV
我有一个全屏运行的应用程序: getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutP
这个问题在这里已经有了答案: Is there any way to change android:windowSoftInputMode value from java class? (5 个答案
在 WebView Activity 上使用 android:windowSoftInputMode="adjustResize" 时,只要用户选择文本输入,其内容就会自行调整大小以启用滚动。 但是,
我在 list 中使用了 android:windowSoftInputMode="adjustResize" 来防止键盘隐藏 Activity 按钮。它可以工作,但是当键盘打开时,我的按钮会向上移动
我将表单包装在 中然后我设置 list android:windowSoftInputMode="adjustResize" (默认 react native )。现在,当我用手指触摸事件手动聚焦一
设置 WindowSoftInputMode 后,我们在 Android 中遇到问题至Android.Views.SoftInput.AdjustResize .当键盘显示或隐藏时,我们的启动屏幕会在
每当我启动应用程序时,软输入都会自动弹出,因为它检测到屏幕上的编辑文本。现在我知道,为了防止这种情况发生,一种方法是将 android:windowSoftInputMode="stateHidden
我正在使用这个库:https://github.com/yshrsmz/KeyboardVisibilityEvent检测键盘何时打开或关闭,这依赖于输入到 Android list 的 androi
我目前正在开发一个简单的笔记应用程序,用户可以在其中输入标题和笔记内容。我想要实现的是,当用户单击注释内容 (EditText) 时,软键盘出现,只有注释内容 EditText 的大小减小(调整大小)
我的 android 应用程序中有以下布局,但 Activity 中的 windowSoftInputMode="adjustResize" 有问题。该布局在屏幕底部包含一个下一步按钮。打开键盘时,按
当键盘显示在我的应用程序上时,我想向上移动我的布局。我在 Activity 中使用了 adjustResize、adjustPan 和它们两者,但它们都不起作用,它仍然在窗体上显示键盘并且不会移动上面
我想要一个按钮,当键盘打开时,它应该粘在底部。 具有长格式的线性布局,在垂直方向上包含多个 edittext。 按钮在scrollview的底部和外面 list 有一个adjustsize 属性 因此
尽管这个问题在stackoverflow中有很多解决方案,但我还是无法解决我的问题。我在屏幕上有两个编辑文本,一个在顶部,另一个附在屏幕底部。每当我点击底部编辑文本时,软键盘就会出现在它上面。我已经玩
我已经在多个 Activity 中成功实现了 AdjustResize,但特别是一个 Activity 在显示键盘时仍然拒绝执行任何操作,除了平移。 知道我做错了什么吗? 我正在像这样使用 xamar
我有一个 WebView(在带有 SlidingTabLayout 的 ViewPager 中的一个 Fragment 中)。 当使用 WebView 进行输入时,我希望调整布局大小以确保输入可见。
我不是在寻找代码,我也不会发布任何代码,只是一个解释,因为我有点迷路了。 这个主要问题是出现软键盘时调整大小。 以我为例 我有一个 listView,其中包含 2 个 editText 和许多使用自定
我的 android 应用程序中有以下布局,但 Activity 中的 windowSoftInputMode="adjustResize" 有问题:名为“container”的 LinearLayo
当键盘打开时,屏幕顶部会出现一条白色 strip ,无论键盘状态如何变化,它都会持续存在。 如果我使用 adjustPan 然后它工作,但是,我只想使用 adjustResize。 这是问题的图片:
在我的 Android 应用程序中,对软键盘使用 adjustResize 行为对我来说至关重要。因此,用户可以向下滚动到其他 UI 元素,例如“继续”按钮。 我注意到 adjustResize 仅在
我是一名优秀的程序员,十分优秀!