我有一个view
其中包含一个CoordinatorLayout
其中包含一个AppBarLayout
and a NestedScrollView
。在 - 的里面NestedScrollView
有一个EditText
我在显示软输入键盘并正确调整其大小时遇到问题view
.
与通常的标志android:windowSoftInputMode="adjustResize"
除了隐藏输入之外,一切似乎都工作正常。
当输入打开时(图 2),NestedScrollView
(带有无聊的灰色背景)已缩小,因此您可以滚动到之前“覆盖”的部分。都好。然而,一旦输入被隐藏(图 3),NestedScrollView
尚未长大以填充空间,您可以看到它的父级CoordinatorLayout
(我把它涂成了漂亮的红色)。
我已经尝试过这个答案https://stackoverflow.com/a/31286789/726954 https://stackoverflow.com/a/31286789/726954,增添了神秘感android:layout_gravity="fill_vertical"
标签,但这只是限制了NestedScrollView
height 最终会切断子元素(尽管它确实解决了拒绝重新填充容器的问题)。
我是否遗漏了什么或者这是一个错误CoordinatorLayout
这是我的 XML 的模型:
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/red_granate">
<android.support.design.widget.AppBarLayout
android:id="@+id/actionBarContainer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fitsSystemWindows="true">
<View
android:id="@+id/statusBarPadding"
android:layout_width="match_parent"
android:layout_height="0dp"
android:background="@color/primary_material_dark"/>
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?android:attr/actionBarSize"
android:background="@color/primary_material_dark"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:layout_scrollFlags="scroll|enterAlways"/>
</android.support.design.widget.AppBarLayout>
<android.support.v4.widget.NestedScrollView
android:background="@color/grey"
android:id="@+id/nestedScrollView"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="2000dp">
<EditText
android:layout_width="100dp"
android:layout_height="wrap_content"
android:layout_marginTop="1900dp"/>
</FrameLayout>
</android.support.v4.widget.NestedScrollView>
</android.support.design.widget.CoordinatorLayout>
您使用的是最新版本 - 22.2.1吗?我在 22.2.0 上也遇到了类似的问题。
compile 'com.android.support:design:22.2.1'
compile 'com.android.support:recyclerview-v7:22.2.1'
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)