1

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

<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>
4

2 回答 2

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"

解决问题。
感谢您的回答。

于 2012-10-10T11:34:41.493 回答
0

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

尝试在你的滚动视图中设置 android:fillViewport="true" 。

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

您可能必须配置清单。以下是软键盘的可能配置列表。它可能是android:windowSoftInputMode="adjustPan"你想要使用的。

于 2012-10-09T11:35:48.207 回答