CoordinatorLayout与NestedScrollView不与adjustResize调整 [英] CoordinatorLayout with NestedScrollView doesn't resize with adjustResize
问题描述
我 A 视图包含一个
CoordinatorLayout
包装了一个 AppBarLayout
和 NestedScrollView
。在 NestedScrollView
有一个的EditText
我有问题,显示了软键盘输入,并让它正确地调整视图
。
与通常的标志的android:windowSoftInputMode =adjustResize
一切似乎是从当你隐藏输入做工精细,分开。
随着输入开路(图片2),在 NestedScrollView
(与枯燥的灰色背景)缩水,所以你可以滚动到previously所覆盖部分。都好。然而,一旦输入被隐藏的图像(见图3),在 NestedScrollView
还没有成长为补充的空间,你可以看到它的父 CoordinatorLayout
(我在取红已经彩色)。
href=\"http://i.stack.imgur.com/s9S6E.png\" rel=\"nofollow\"> 的
我试过这个答案 http://stackoverflow.com/a/31286789/726954 ,加入myserious 的android:layout_gravity =fill_vertical
标签,但所有这确实是限制 NestedScrollView
高度从而结束了切断孩子元素(虽然它确实有它拒绝填充它的容器解决问题)。
我缺少的东西,或这是一个错误的 CoordinatorLayout
下面是我的XML的样机:
<?XML版本=1.0编码=UTF-8&GT?;
< android.support.design.widget.CoordinatorLayout
的xmlns:机器人=http://schemas.android.com/apk/res/android
的xmlns:程序=http://schemas.android.com/apk/res-auto
机器人:layout_width =match_parent
机器人:layout_height =match_parent
机器人:背景=@色/ red_granate> < android.support.design.widget.AppBarLayout
机器人:ID =@ + ID / actionBarContainer
机器人:layout_width =match_parent
机器人:layout_height =WRAP_CONTENT
机器人:fitsSystemWindows =真正的> <查看
机器人:ID =@ + ID / statusBarPadding
机器人:layout_width =match_parent
机器人:layout_height =0dp
机器人:背景=@色/ primary_material_dark/> < android.support.v7.widget.Toolbar
机器人:ID =@ + ID /工具栏
机器人:layout_width =match_parent
机器人:layout_height =机器人:ATTR / actionBarSize
机器人:背景=@彩色/ primary_material_dark
机器人:主题=@风格/ ThemeOverlay.AppCompat.Dark.ActionBar
应用:layout_scrollFlags =滚动| enterAlways/>
< /android.support.design.widget.AppBarLayout> < android.support.v4.widget.NestedScrollView
机器人:背景=@彩色/灰度
机器人:ID =@ + ID / nestedScrollView
机器人:layout_width =match_parent
机器人:layout_height =match_parent
应用:layout_behavior =@字符串/ appbar_scrolling_view_behavior> <的FrameLayout
机器人:layout_width =match_parent
机器人:layout_height =2000DP> <的EditText
机器人:layout_width =100dp
机器人:layout_height =WRAP_CONTENT
机器人:layout_marginTop =1900dp/>
< /&的FrameLayout GT;
< /android.support.v4.widget.NestedScrollView>
< /android.support.design.widget.CoordinatorLayout>
您使用最新版本 - 22.2.1?我有类似的问题22.2.0。
编译com.android.support:design:22.2.1
编译com.android.support:recyclerview-v7:22.2.1
I have a view
which contains a CoordinatorLayout
which wraps an AppBarLayout
and a NestedScrollView
. Inside the NestedScrollView
there is an EditText
I'm having problems showing the soft input keyboard and having it correctly resize the view
.
With the usual flag android:windowSoftInputMode="adjustResize"
everything seems to work fine, apart from when you hide the input.
With the input open (image 2), the NestedScrollView
(with the boring grey background) has shrunk so you can scroll to the previously "covered" portion. All good. However, once the input is hidden (image 3), the NestedScrollView
has not grown to refill the space and you can see it's parent CoordinatorLayout
(which I've coloured in the fetching red).
I've tried this answer http://stackoverflow.com/a/31286789/726954, adding a myserious android:layout_gravity="fill_vertical"
tag, but all this does is limit the NestedScrollView
height which ends up cutting off child elements (although it does fix the problem with it refusing to refill it's container).
Am I missing something or is this a bug with the CoordinatorLayout
Here is a mockup of my 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>
Are you using the latest version - 22.2.1? I had similar problems with 22.2.0.
compile 'com.android.support:design:22.2.1'
compile 'com.android.support:recyclerview-v7:22.2.1'
这篇关于CoordinatorLayout与NestedScrollView不与adjustResize调整的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!