android - ScrollView 不响应键盘

标签 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 中滚动,但即使键盘关闭也显示滚动。我不能使用固定高度。

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

相关文章:

java - 在 Android 布局中挖洞

java - 在圆霍夫变换中,累加器分辨率 (dp) 的反比​​是多少?它如何影响圆检测?

java - 如何通过 spannable 方法使用自定义字体设置所选文本的字体样式

android - 带有 ListView 的 ScrollView 不滚动 - android

android - 如何让谷歌地图在 ScrollView 中正确滚动?

android - 将 View 动态添加到 fragment 内的 ScrollView

android - 当 NestedScrollView 为空时停止 AppBarLayout 滚动屏幕

android - 为什么打开键盘时键盘会与我的 View 内容重叠

android - 带有 EditText 的 AlertDialog 的更好解决方案

android - PreferenceEditText 到字符串