gpt4 book ai didi

android - 在 CoordinatorLayout 中滚动时工具栏不会折叠

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

我正在使用以下布局文件来实现带有折叠工具栏的协调器布局(当用户向下滚动时,它应该折叠,并在他们向上滚动时重新出现)但是,这种滚动屏幕/折叠功能不起作用,并且我不知道为什么。工具栏和标签栏没有反应,而是静态地停留在屏幕顶部。

<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">

<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<!-- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >

<Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Alpha" />
<Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Beta" />
<!-- a bunch of content just to make the view long enough to scroll -->
<Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Upsilon" />

</LinearLayout>

</ScrollView>


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

<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorAccent"
app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
app:layout_scrollFlags="scroll|enterAlways" />
<!-- ^^^^^^^^^^^^^^^^^^ -->

<android.support.design.widget.TabLayout
android:id="@+id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_scrollFlags="scroll|enterAlways" />
<!-- ^^^^^^^^^^^^^^^^^^ -->

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

<android.support.design.widget.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_margin="@dimen/fab_padding"
android:src="@drawable/ic_add"/>

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

有什么帮助吗?谢谢!

最佳答案

据我所知,ScrollView不起作用。您可以使用 NestedScrollViewRecyclerView相反。

关于android - 在 CoordinatorLayout 中滚动时工具栏不会折叠,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32448579/

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