gpt4 book ai didi

android - 带有 NestedScrollView 的 CoordinatorLayout 不会使用 adjustResize 调整大小

转载 作者:太空宇宙 更新时间:2023-11-03 13:18:40 25 4
gpt4 key购买 nike

我有一个 view,它包含一个 CoordinatorLayout,它包装了一个 AppBarLayout 和一个 NestedScrollView。在 NestedScrollView 中有一个 EditText

我在显示软输入键盘和正确调整 view 大小时遇到​​问题。

使用通常的标志 android:windowSoftInputMode="adjustResize" 一切似乎都工作正常,除了隐藏输入时。

随着输入打开(图 2),NestedScrollView(具有乏味的灰色背景)已经缩小,因此您可以滚动到之前“覆盖”的部分。都好。但是,一旦输入被隐藏(图 3),NestedScrollView 就不会增长以填充空间,您可以看到它的父级 CoordinatorLayout(我在获取红色)。

enter image description here enter image description here enter image description here

我试过这个答案 https://stackoverflow.com/a/31286789/726954 ,添加一个神秘的 android:layout_gravity="fill_vertical" 标签,但这所做的只是限制 NestedScrollView 高度,最终切断子元素(尽管它确实解决了问题它拒绝重新填充它的容器)。

我是不是遗漏了什么或者这是 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'

关于android - 带有 NestedScrollView 的 CoordinatorLayout 不会使用 adjustResize 调整大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32074090/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com