ScrollView不响应键盘

时间:2012-10-09 11:29:04

标签: android android-edittext android-scrollview

我在ScrollViews中有EditText滚动行为的问题,通常它会在滚动内容滚动内容,如果键盘打开它。但是如果你动态地填充scrollview中的布局,键盘会推动整个屏幕,之前其他任何人都有这个问题。 提前谢谢。

<ScrollView
    android:id="@+id/scroll_view"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_below="@+id/header_area" >

        <LinearLayout
            android:id="@+id/contentHolder"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical" >
        </LinearLayout>
</ScrollView>

此示例在滚动视图中按正常,线性布局滚动,但它显示滚动甚至键盘关闭。我不能使用固定的高度。

 <ScrollView
        android:id="@+id/scroll_view"
        android:layout_width="fill_parent"
        android:layout_height="100dip"
        android:layout_below="@+id/header_area" >

            <LinearLayout
                android:id="@+id/contentHolder"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:orientation="vertical" >
            </LinearLayout>
    </ScrollView>

我在下面尝试了xml,它在新项目中按预期工作,但在我的项目中推送窗口。我发现其他人有这个问题,我会尽快分享解决方案。

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/mainLayout"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical">


    <RelativeLayout
        android:id="@+id/header_area"
        android:layout_width="match_parent"
        android:layout_height="50dip" >
    </RelativeLayout>

    <ScrollView
        android:id="@+id/scroll_view"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent">

        <LinearLayout
            android:id="@+id/contentHolder"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:orientation="vertical" >

            <EditText 
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"/>
            <EditText 
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"/>
            <EditText 
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"/>
            <EditText 
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"/>
            <EditText 
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"/>
            <EditText 
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"/>
        </LinearLayout>
    </ScrollView>

</LinearLayout>

2 个答案:

答案 0 :(得分:2)

<application
    android:icon="@drawable/is_logo_iphone"
    android:label="@string/app_name"
    android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen" >

问题是“全屏”主题不支持调整大小。使用

    android:theme="@android:style/Theme.Black.NoTitleBar"

解决了这个问题。
谢谢你的回答。

答案 1 :(得分:0)

这是因为您的滚动视图可以调整大小。尝试将scrollview的高度设置为match_parent。

尝试在您的滚动视图中设置android:fillViewport =“true”。

此外,你不会在你的清单的活动标签中添加类似跟随的内容:android:windowSoftInputMode="adjustResize"这几乎会毁掉我们所有的努力。如果您在清单中有以下内容,请删除它。

您可能需要配置清单。 Here is a list软键盘的可能配置。您可能想要使用android:windowSoftInputMode="adjustPan"

相关问题