键盘隐藏留下空的空白

时间:2015-07-10 04:57:45

标签: android android-softkeyboard

我有一个问题,比如在我的键盘弹出并隐藏后,键盘所在的位置是空的。我ScrollView内只有很少的组件。

<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_margin="@dimen/activity_horizontal_margin"
    android:orientation="vertical">

    <android.support.design.widget.TextInputLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <EditText
            android:id="@+id/state"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:hint="@string/hint_state" />
    </android.support.design.widget.TextInputLayout>

    <android.support.design.widget.TextInputLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <EditText
            android:id="@+id/district"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:hint="@string/hint_district" />

    </android.support.design.widget.TextInputLayout>

    <android.support.design.widget.TextInputLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <AutoCompleteTextView
            android:id="@+id/police_station"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:hint="@string/hint_station" />

    </android.support.design.widget.TextInputLayout>

    <include
        android:id="@+id/vehicle_type"
        layout="@layout/template_cascading_spinner"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_margin="5dp" />

    <include
        android:id="@+id/vehicle_manufacturer"
        layout="@layout/template_cascading_spinner"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_margin="5dp" />

    <include
        android:id="@+id/vehicle_model"
        layout="@layout/template_cascading_spinner"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_margin="5dp" />

    <include
        android:id="@+id/registration_no"
        layout="@layout/template_registration_no"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_margin="5dp" />

    <android.support.design.widget.TextInputLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <AutoCompleteTextView
            android:id="@+id/engine_no"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:hint="@string/hint_station" />

    </android.support.design.widget.TextInputLayout>

    <android.support.design.widget.TextInputLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <AutoCompleteTextView
            android:id="@+id/chassis_no"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:hint="@string/hint_station" />

    </android.support.design.widget.TextInputLayout>

    <include
        android:id="@+id/capture_image"
        layout="@layout/template_image_control"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginBottom="5dp"
        android:layout_marginTop="5dp" />

</LinearLayout>

</ScrollView>

和它的ScreenShot。

enter image description here

我没有找到任何理由为什么会发生这种情况。任何帮助都会有所帮助。

注意: 我用Google搜索足以找到解决方案,在windowBackground中添加styles.xml没有帮助。我找不到使用它的正当理由。

我也尝试过不添加TextInputLayout。但结果是一样的。

在所有版本的Android中都会发生。

1 个答案:

答案 0 :(得分:1)

我设法在打破了我的头脑后想出来。这是由于我在活动中使用android.support.design.widget.CoordinatorLayout而发生的。

以上xml是附加到MainActivity的片段。在主要活动XML中,我将CoordinateLayout作为父级。我认为使用CoordinateLayoutScrollView可能存在一些错误。

暂时将其更改为LinearLayout修复了我的问题。

相关问题