我在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>

最佳答案

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


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

关于android - ScrollView不响应键盘,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/12799060/

10-11 00:44
查看更多