简体   繁体   English

弹出软键盘时,保持视图组可见

[英]Keep viewgroup visible when soft keyboard pops up

Typically, when dealing with soft keyboards, we can specify the layout to resize or pan up when the text field will be hidden. 通常,在处理软键盘时,我们可以指定布局以在隐藏文本字段时调整大小或平移。

I have the following layout: 我有以下布局:

在此输入图像描述

Due to the way it is created (large margin on the bottom from the card), resizing will not work well as it will leave a big gap between the keyboard and the card. 由于它的创建方式(卡底部的大边距),调整大小不会很好,因为它会在键盘和卡之间留下很大的差距。

Panning however will keep the password textfield hidden if the username textfield is focused. 但是,如果关注用户名文本字段,则平移将保持密码文本字段隐藏。

Is there a way to specify how far the views should pan, such that it pans up until the FAB? 有没有办法指定视图应该平移多远,以便它直到FAB?

The only other solution I can think of is to change my padding based on width measure changes, but that sounds like a slightly hacky solution 我能想到的唯一其他解决方案是根据宽度测量值的变化来改变我的填充,但这听起来像是一个有点hacky的解决方案

Your only choices with the softkeyboard are to pan, resize or do nothing. 软键盘的唯一选择是平移,调整大小或什么都不做。 There are no options to effect things like how far it pans. 没有选择可以影响它的平移范围。

The password field may or may not be hidden if the username field is focused. 如果关注用户名字段,则可以隐藏或不隐藏密码字段。 It depends on the size of the screen, height of the keyboard, and your exact layout on that device. 这取决于屏幕的大小,键盘的高度以及该设备上的确切布局。 But your best solution is probably to make the action key for the username to be ACTION_NEXT and define action next to focus the password field. 但是,您最好的解决方案可能是将用户名的操作键设置为ACTION_NEXT,并在焦点密码字段旁边定义操作。

Another good solution would be to get rid of a lot of the negative space above the card- unless there's something there you aren't showing us, its wasted space and placing the card higher on the screen will solve all your problems. 另一个好的解决方案是摆脱卡上面的大量负面空间 - 除非你没有向我们展示它的东西,它浪费的空间并将卡放在屏幕上会解决你所有的问题。

You should add 你应该添加

<activity android:windowSoftInputMode="stateVisible|adjustResize"/>

in your Manifest to your Activity I think. 在你的宣言中我认为你的活动。 Can't verify right now. 现在无法验证。 Check out more at the Android Developers Documentation Android开发者文档中查看更多信息

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

相关问题 弹出“软键盘”时禁用后退按钮,Android - Disable back button when Soft Keyboard pops up, Android Android:弹出软键盘时如何捕捉事件? - Android: how to catch the event when the soft keyboard pops up? adMob 横幅在软键盘弹出时覆盖文本视图 - adMob banner covers text view when soft keyboard pops up Firemonkey:当VKAutoShowMode为Never时,软键盘弹出 - Firemonkey: Soft Keyboard pops up when VKAutoShowMode is Never 弹出软键盘时如何仅隐藏部分布局 - How to hide only part of layout when soft keyboard pops up Android软键盘弹出并自动隐藏 - Android soft keyboard pops up and hides automatically 软键盘在Activity上显示,但在三星手机上弹窗后软键盘闪烁时 - When the soft keyboard is shown on Activity, but the software keyboard flashes after the popupwindow pops up on the Samsung mobile phone 可见软键盘时防止线性布局向上移动 - Preventing linear layout from moving up when soft keyboard is visible Android上的Flex:弹出软键盘时,应用程序屏幕变黑 - Flex on Android: App screen goes black when the soft keyboard pops up 软键盘弹出后滚动到某个点,而不是之前 - Scroll To Certain Point after Soft Keyboard Pops up, Not Before
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM