[英]android resize layout when keyboard appears
I would like to reposition layout when keyboard appears, for example when editing a text field, in order to get visibility on focused field. 我想在键盘出现时重新定位布局,例如在编辑文本字段时,以便在聚焦字段上获得可见性。 I tried windowSoftInputMode but I cannot get any difference.
我试过windowSoftInputMode,但我没有任何区别。 How to reach it?
怎么到达? Thank you.
谢谢。
<activity
android:name="com.xxxx.projecte1.TabBar_Activity"
android:theme="@android:style/Theme.NoTitleBar"
android:configChanges="keyboardHidden|orientation|screenSize"
android:windowSoftInputMode="adjustResize"
/>
<activity
android:name=".WActivity"
android:configChanges="orientation|keyboard|keyboardHidden|screenSize|screenLayout|uiMode"
android:icon="@drawable/navigation_two"
android:label="@string/app_name"
android:screenOrientation="portrait"
android:theme="@style/appTheme"
android:windowSoftInputMode="adjustResize" />
What fixed it in my case was just putting 在我的案例中修正它的原因就在于
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
into my activity's onCreate
method. 进入我的活动的
onCreate
方法。
Without any xml changes whatsoever, since those did not work for me whatsoever, but this worked right away like a charm. 没有任何xml变化,因为那些对我来说不起作用,但这就像魅力一样。 Although an xml solution seems nicer to me, even the same parameter did not work.
虽然xml解决方案对我来说似乎更好,但即使是相同的参数也不起作用。
Sharing it since I did not find a quick and easy fix myself online. 分享它,因为我没有在网上找到一个快速简单的解决方案。
I believe the problem is this line 我相信这个问题就是这条线
android:configChanges="keyboardHidden|orientation|screenSize"
in your code. 在你的代码中。 This line tells the
Android
that your Activity
will handle this 3 events on its own. 这一行告诉
Android
你的Activity
将自己处理这3个事件。 If you remove this line, i believe you will have the desired effect. 如果你删除这一行,我相信你会有所期望的效果。
See here for the configChanges
attribute. 请参阅此处了解
configChanges
属性。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.