带有 NestedScrollView 的 CoordinatorLayout 不会通过 adjustmentResize 调整大小

2024-02-22

我有一个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"标签,但这只是限制了NestedScrollViewheight 最终会切断子元素(尽管它确实解决了拒绝重新填充容器的问题)。

我是否遗漏了什么或者这是一个错误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(使用前将#替换为@)

带有 NestedScrollView 的 CoordinatorLayout 不会通过 adjustmentResize 调整大小 的相关文章

随机推荐

  • wget:无法解析主机地址“github.com”

    我正在使用 Redhat UBI 映像构建 dockerfile 当我构建映像时 我得到 wget 无法解析主机地址 github com 我尝试添加一个不以 GitHub 开头的不同 URL 但该 URL 有效 不确定是什么问题 以下是我
  • NSFetchedResultsController 在 objectAtIndexPath 上崩溃?

    我在尝试访问以下对象时发生崩溃NSFetchedResultsController 2013 11 10 15 15 06 568 Social 11503 70b CoreData error Serious application er
  • 在 C#.NET 中动态转换为类型

    替代标题 在运行时动态转换为类型 我想将对象转换为将在运行时分配的类型 例如 假设我有一个分配字符串值的函数 来自TextBox or Dropdownlist to an Object Property 我如何将值转换为正确的类型 例如
  • 如何设置包装给定函数的函数的类型

    我正在做一个简单的memoize函数 它的作用是接受一个函数 并在缓存返回结果的地方做一些魔法 但基本上返回函数的类型memoize与给定的完全相同 但我遇到了错误 我不知道如何修复 当使用该函数并忽略我遇到的错误时 这些类型可以工作 我已
  • 用户代理字符串可以有多大?

    如果您要将用户代理存储在数据库中 您会容纳多大的数据库 我找到了这个技术网文章 http technet microsoft com en us library bb496341 aspx建议将 UA 保持在 200 以下 HTTP 规范中
  • PHP base64_decode C# 等效项

    我正在尝试模仿执行以下操作的 php 脚本 用 号替换 GET 变量的每个空格 var preg replace s GET var 解码为 Base64 base64 decode var 首先我添加了一个执行 Base64 解码的方法
  • 无符号整数取负值[重复]

    这个问题在这里已经有答案了 有人可以解释为什么 unsigned int 取负值吗 一个unsigned int应该只取正值 From 维基百科 http en wikipedia org wiki Integer 28computer s
  • 更改 nginx 工作进程运行的用户(Ubuntu 12.04)

    我在 Ubuntu 12 04 上手动安装了 nginx 当我跑的时候 configure我使用了以下选项 configure user www data group www data with http ssl module with h
  • 如何将此 csv 数据转换为条形图?

    旅游 旅游名称 开始 开始时的可用预订 结束 剩余预订量 csv 文件列 ID Tour Start End 12345 Italy 100 80 13579 China 50 30 24680 France 50 30 到目前为止我有这个
  • Ruby——寻找某种“Regexp unescape”方法

    我有一堆带有特殊转义代码的字符串 我想存储未转义的代码 例如 解释器显示 014 000 016smoothing 011mean 022color 011zero 016 但我希望它显示 检查时 为 014 000 016smoothin
  • 为了使用 Scrapy 正确发送电子邮件,我忘记了什么

    我想使用 Scrapy 发送电子邮件 我看了 throw 官网 发现可以这样做 from scrapy mail import MailSender from scrapy utils project import get project
  • 如何返回我在嵌套数组中查找的元素?

    我有一个这样的数据库 universe comics saga name x men characters character wolverine picture 618035022351 png character cyclops pic
  • Python 自由变量。为什么会失败?

    以下代码打印 123 gt gt gt a 123 gt gt gt def f print a gt gt gt f 123 gt gt gt 但以下失败 gt gt gt a 123 gt gt gt def f print a a 4
  • 比较内部消息传递的两种数据库设计

    以下哪种数据库设计更适合内部消息系统 三张表 MessageThread models Model subject timestamp creator Message models Model thread pk content times
  • 从右到左数据网格视图单元格

    如何将属性从右到左设置为 Datagridview 单元格 我尝试设置 Alignment 属性为 MiddleRight 但由于我的 DatagridviewCell 值为 阿拉伯语和英语没有按照我想要的从右到左显示 我找到了一个带有 C
  • 限制后获取另一个订单

    想象一下 我有一个表 用户 其中包含两个字段 年龄 和 姓名 我想检索前十名老用户 然后我希望这十个用户的列表按名称排序 可以用MySQL来做吗 我试过这个 不起作用 SELECT FROM users order by age name
  • 将元素与窗口底部对齐,但允许滚动到下方的内容

    我现在正在编写一个 jquery 滑块 并将宽度设置为 100 并且无论窗口如何调整大小 我都希望它与窗口底部对齐 我已经找到了让它在向下滚动时一直粘在底部的方法 但我不希望这样 我希望能够滚动到此滑块下方以获取更多内容 这个网站展示了我正
  • 如何让 CSS 文本装饰覆盖起作用?

    有些日子我发誓我要疯了 这是那些日子之一 我认为我的 CSS 在这里相当简单 但它似乎不起作用 我缺少什么 我的 CSS 看起来像这样 ul gt li text decoration none ul gt li u text decora
  • Cocoa:为什么我的表格视图是空白的?

    为什么我的表格视图是空白的 一切都很好 直到我添加 initWithStyle 它看起来是这样的 这是我的代码的样子 这是我的 h import
  • 带有 NestedScrollView 的 CoordinatorLayout 不会通过 adjustmentResize 调整大小

    我有一个view其中包含一个CoordinatorLayout其中包含一个AppBarLayout and a NestedScrollView 在 的里面NestedScrollView有一个EditText 我在显示软输入键盘并正确调整