android – 如何在显示软键盘时保持所有字段和文本可见

android – 如何在显示软键盘时保持所有字段和文本可见,第1张

概述我正在这个登录屏幕上工作,我希望在显示IME时调整所有字段,文本和按钮的大小.我已经在 androidManifest.xml上使用了android:windowSoftInputMode =“adjustResize”,但我仍然在其他人之下获得了一些元素. 如果TextView“Cadastre Agora”(id = cadastrar)仍被虚拟键盘覆盖,我无所谓.但是,只要元素很少,我就会尝 我正在这个登录屏幕上工作,我希望在显示IME时调整所有字段,文本和按钮的大小.我已经在 androidManifest.xml上使用了androID:windowsoftinputMode =“adjustResize”,但我仍然在其他人之下获得了一些元素.

如果TextVIEw“Cadastre Agora”(ID = cadastrar)仍被虚拟键盘覆盖,我无所谓.但是,只要元素很少,我就会尝试至少使EditTexts(及其TextVIEws)和按钮可见.

我发现这个未解决的问题可能是一个有趣的方法:http://stackoverflow.com/ questions / 6484024 / soft-keyboard-keep-one-vIEw-stationary-while-moving-other

谢谢你的帮助!

没有IME的屏幕:http://imageshack.us/photo/my-images/138/semttulo2mr.png/

使用IME的屏幕(TextVIEw1变为隐藏):http://imageshack.us/photo/my-images/404/semttulo3xw.png/

Stackoverflow抱怨我的代码格式化,所以我在这里上传了xml文件:https://rAPIdshare.com /files/1767398103/login.xml
我不能发布超过2个链接,这就是为什么我在其中放置空格.

解决方法 在这种情况下,我会说你的初始布局(没有键盘显示)已经存在问题.鉴于您正在创建纯粹是登录屏幕的内容,可以将所有控件放在屏幕的上半部分,并在用户访问页面时自动显示键盘.这使用户体验更快,并且您无需提供灵活的布局.

但是,如果您想尝试在两个视图中使布局工作,则需要将间距更改为控件之间的动态.

例如:

<linearLayout xmlns:androID="http://schemas.androID.com/apk/res/androID"    androID:layout_wIDth = "fill_parent"    androID:layout_height = "fill_parent"    androID:orIEntation="vertical"    >    <Space         androID:layout_height="fill_parent"        androID:layout_wIDth="fill_parent"        androID:layout_weight="1">        <!-- Username Controls here -->    <Space         androID:layout_height="fill_parent"        androID:layout_wIDth="fill_parent"        androID:layout_weight="1">        <!-- Password Controls here -->    <Space         androID:layout_height="fill_parent"        androID:layout_wIDth="fill_parent"        androID:layout_weight="1">        <!-- Login button here -->    <Space         androID:layout_height="fill_parent"        androID:layout_wIDth="fill_parent"        androID:layout_weight="1">        <!-- TextVIEw here -->    <Space         androID:layout_height="fill_parent"        androID:layout_wIDth="fill_parent"        androID:layout_weight="1"></linearLayout>

为了使其正常工作,必须从控件中删除所有垂直填充,但文本框标签之间的填充除外.

总结

以上是内存溢出为你收集整理的android – 如何在显示软键盘时保持所有字段和文本可见全部内容,希望文章能够帮你解决android – 如何在显示软键盘时保持所有字段和文本可见所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/1126574.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-30
下一篇 2022-05-30

发表评论

登录后才能评论

评论列表(0条)

保存