gpt4 book ai didi

android - "match_parent"高度不适用于 NestedScrollView 内的 RelativeLayout

转载 作者:行者123 更新时间:2023-12-03 15:04:11 25 4
gpt4 key购买 nike

我在 activity.xml 中使用 CoordinatorLayout 作为我的 Root View 。在那个 xml 中,我使用的是 嵌套 ScrollView 启用 appbar_scrolling_view_behavior。但是 NestedScrollView 内的内容是包装高度而不是匹配父项。

这是我的布局 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"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/white">

<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">

<android.support.v7.widget.Toolbar
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_scrollFlags="scroll|enterAlways|snap">
</android.support.v7.widget.Toolbar>
</android.support.design.widget.AppBarLayout>

<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior">

<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ProgressBar
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"/>

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/content"
android:padding="20dp"
android:visibility="gone"/>
</RelativeLayout>


</android.support.v4.widget.NestedScrollView>


</android.support.design.widget.CoordinatorLayout>

这是布局预览 enter image description here

最佳答案

只需添加 NestedScrollView

 android:fillViewport="true"

关于android - "match_parent"高度不适用于 NestedScrollView 内的 RelativeLayout,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44303681/

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