gpt4 book ai didi

java - Android Constraint Layout Render问题在NestedScrollView中

转载 作者:太空宇宙 更新时间:2023-11-03 11:38:58 24 4
gpt4 key购买 nike

我正在尝试将我的 ConstraintLayout 添加到 NestedScrollView。当观察我的 ContraintLayout 时,一切看起来都很好。

但是然后将布局包含到我的 NestedScrollView 中会折叠 ContraintLayout。(即使我在包含和我的 CL 中使用匹配父宽度/高度)

这实际上是先前版本的 ContraintLayout(~pre Beta)中的错误。 Google Bug Reports

我在 Verion beta4 中遵循这种方法。 Link to Youtube AndroidDev Channel

constraint_layout.xml:

<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:id="@+id/coordinator_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context="de.project.andy.aliver.JobCreatorActivity">

<include layout="@layout/content_job_creator" />

<android.support.design.widget.AppBarLayout
android:id="@+id/app_bar"
android:layout_width="match_parent"
android:layout_height="145dp"
android:fitsSystemWindows="true"
android:theme="@style/AppTheme.AppBarOverlay">

<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/toolbar_layout"
android:layout_width="match_parent"
android:layout_height="143dp"
android:fitsSystemWindows="true"
app:contentScrim="?attr/colorPrimary"
app:layout_scrollFlags="scroll|exitUntilCollapsed">

<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:layout_collapseMode="pin"
app:popupTheme="@style/AppTheme.PopupOverlay" />

</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>

<android.support.design.widget.FloatingActionButton
android:id="@+id/jc_fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@android:drawable/arrow_up_float"
android:layout_gravity="end|bottom"
app:fabSize="normal"
android:layout_margin="15dp" />
</android.support.design.widget.CoordinatorLayout>

nested_scrollview_layout.xml:

<android.support.v4.widget.NestedScrollView 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"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context="de.project.andy.aliver.JobCreatorActivity"
tools:showIn="@layout/activity_job_creator">

<include layout="@layout/constraint_layout"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</android.support.v4.widget.NestedScrollView>

有解决办法吗?

最佳答案

天哪...研究了一个小时还没有答案。创建 SO 帖子并在 5 分钟后找到答案。

上面描述的这个问题在ScrollView中是一样的。解决方案是添加

android:fillViewport="true"

到可滚动的父级。

因此 nested_scrollview_layout.xml 将是:

<android.support.v4.widget.NestedScrollView 
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:fillViewport="true"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context="de.project.andy.aliver.JobCreatorActivity"
tools:showIn="@layout/activity_job_creator">

<include layout="@layout/constraint_layout"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</android.support.v4.widget.NestedScrollView>

关于java - Android Constraint Layout Render问题在NestedScrollView中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41533614/

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