滚动视图滚动时如何隐藏和显示材质工具栏?

问题描述 投票:1回答:1

在我的Android应用程序中,我正在ScrollView内建立一个简单的RelativeLayout!它还有一个材料Toolbar。当用户向上滚动并在用户向下滚动时显示工具栏时,如何使材质工具栏隐藏?这是我的应用程序的xml布局结构。

<RelativeLayout>
    <AppBarLayout>
        <Toolbar/>
    </AppBarLayout>

    <ScrollView> 
        <!-- views -->
    </ScrollView>
</RelativeLayout>
android material-design toolbar
1个回答
2
投票

使用带有CollapsingToolbarLayout的NestedScrollView

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

Try this working example

© www.soinside.com 2019 - 2024. All rights reserved.