安卓:滚动型不带键盘的滚动出不带、键盘

由网友(我真的受伤了)分享简介:我有一些意见,从其中一个是一个EditText的布局。布局能够装在一个页面上,但是,当软键盘出来,布局不会滚动。这是我的布局表现:I've got a layout with some views, from which one is an EditText. The layout easily fits on o...

我有一些意见,从其中一个是一个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?

在此先感谢!

推荐答案

好了,显然是滚动型的安卓layout_height 一定不能设置为 WRAP_CONTENT 。我将它设置为 match_parent ,并设置机器人: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.

阅读全文

相关推荐

最新文章