Android:ScrollView 不使用键盘滚动 [英] Android: ScrollView not scrolling with keyboard out

查看:30
本文介绍了Android:ScrollView 不使用键盘滚动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带有一些视图的布局,其中一个是 EditText.布局很容易适合一页,但是,当软键盘关闭时,布局不会滚动.这是我的布局的回顾:

I've got a layout with some views, from which one is an EditText. The layout easily fits on one page, BUT, when the soft keyboard is out, the layout doesn't scroll. Here's a recap of my layout:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/background" >

    <ScrollView
        android:id="@+id/ScrollView1"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true" >

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical" >

            <CheckBox/>

            <TextView/>

            <LinearLayout>
                <EditText>
                    <requestFocus />
                </EditText>
            </LinearLayout>

            <TextView/>

            <LinearLayout>
                <Spinner/>
            </LinearLayout>

        </LinearLayout>

    </ScrollView>

    <Button
        android:layout_alignParentBottom="true" />

</RelativeLayout>

在我的清单中,我已经声明了该属性:

And in my manifest I have declared the attribute:

android:windowSoftInputMode="adjustResize|stateHidden"

有人知道为什么它不起作用以及如何确保它起作用吗?

Does anyone know why it doesn't work and how to make sure it does work?

提前致谢!

推荐答案

好吧,显然 ScrollView 的 android:layout_height 不能设置为 wrap_content.我将其设置为 match_parent 并将 android:layout_above 设置为页面底部的按钮.

Okay, apparently the ScrollView's android:layout_height mustn't be set to wrap_content. I set it to match_parent and set the android:layout_above to the button on the bottom of the page.

不要问我为什么,但这解决了问题.

Don't ask me why, but this fixed the issue.

这篇关于Android:ScrollView 不使用键盘滚动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆