简体   繁体   中英

Keyboard hide leaves empty blank space

I have an issue like after my keyboard pops up and hides there is an empty space where ever the keyboard was. I have nothing but few components inside 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>

And ScreenShot of it.

在此处输入图片说明

I didn't find any reason yet why this is happening. Any Help will be helpful.

NOTE : I Googled enough to find the solutions, adding the windowBackground in styles.xml didn't help. And I don't find valid reason to use that.

I also tried without adding TextInputLayout . But the result was same.

Happening in all versions of Android.

I managed to figure it out after breaking my head. This was happening due to android.support.design.widget.CoordinatorLayout which I used in activity.

The above xml is a fragment attached to the MainActivity . In Main Activity XML I have CoordinateLayout as parent. I think there might be some bug with using CoordinateLayout along with ScrollView .

Changing it to LinearLayout fixed my issue for now.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM