[英]Keyboard hide leaves empty blank space
我有一个问题,例如键盘弹出并隐藏后,键盘所在的位置都有一个空白空间。 除了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。
我至今仍未找到任何原因。 任何帮助都会有所帮助。
注意:我用Google搜索了足够的解决方案,在styles.xml
添加windowBackground
并没有帮助。 而且我没有找到使用它的正当理由。
我也尝试不添加TextInputLayout
。 但是结果是一样的。
发生在所有版本的Android中。
我摔断头后设法弄清楚了。 这是由于我在活动中使用的android.support.design.widget.CoordinatorLayout
而发生的。
上面的xml
是附加到MainActivity
的片段。 在主要活动XML中,我将CoordinateLayout
作为父级。 我认为将CoordinateLayout
和ScrollView
一起使用可能会出现一些错误。
将其更改为LinearLayout
解决了我的问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.