显示键盘时活动未调整大小 [英] Activity isn't resizing when keyboard is shown
本文介绍了显示键盘时活动未调整大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个简单的活动,其中显示了一个大的多行EditText
及其下面的一些其他控件.我希望调整活动的大小,以便在用户键入EditText
时键盘不会隐藏按钮.
I have a simple activity that displays a big multiline EditText
and some other controls below it. I want the activity to resize so the buttons are not hidden by the keyboard when the user is typing in the EditText
.
我尝试了在网上找到的各种粗略和非粗略的解决方案-没什么用.
I have tried all sorts of sketchy and non-sketchy solutions I have found online - nothing works.
这是我到目前为止尝试过的:
Here's what I've tried so far:
- 将
android:windowSoftInputMode="adjustResize"
放入清单中. - 将
android:fitsSystemWindows="true"
放在布局根目录中. - 使用
RelativeLayout
与LinearLayout
作为根. - 从活动中删除了所有主题
- 创建了一个自定义主题并将
<item name="android:windowFullscreen">false</item>
放入其中. - 在此处中尝试了建议的解决方案,而我的整个活动布局都放在了
ScrollView
中.
- Putting
android:windowSoftInputMode="adjustResize"
in the manifest. - Putting
android:fitsSystemWindows="true"
in the layout root. - Using
RelativeLayout
vs.LinearLayout
as root. - Removed all themes from the activity
- Created a custom theme and put
<item name="android:windowFullscreen">false</item>
in it. - Tried the proposed solution here, with my entire activity layout inside a
ScrollView
.
还有什么可以尝试的吗?
Anything left to try?
推荐答案
在您的onCreate()
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
然后,当键盘显示/隐藏在屏幕中时,您的活动将自动上/下推.
Then your Activity will automatically push up/down when , Key Board shown/hide in screen.
使用清单文件进行设置对我不起作用.
Setting up with , Manifest file , didn't work for me.
这篇关于显示键盘时活动未调整大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文