[英]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.