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

我正在这个登录屏幕上工作,我希望在显示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>

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

点赞