Two Toolbars, Only the second one should collapse on scroll in CoordinatorLayout(两个工具栏,只有第二个工具栏应该在坐标布局中滚动时折叠)
本文介绍了两个工具栏,只有第二个工具栏应该在坐标布局中滚动时折叠的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在一个协调员布局中有以下代码。这段代码的主要作用是将两个工具栏放在彼此的顶部See Image Here。我计划实现的是,当用户向下滚动时,只有第二个工具栏折叠。
<android.support.design.widget.AppBarLayout
android:id="@+id/toolbar_home_appBarLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.Toolbar
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:id="@+id/toolbar"
android:background="?attr/colorPrimary"
app:theme = "@style/ThemeOverlay.AppCompat.Dark.ActionBar">
</android.support.v7.widget.Toolbar>
<android.support.v7.widget.Toolbar
app:layout_scrollFlags="scroll|enterAlways|snap"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/toolbar_filters"
android:background="@color/colorAccent"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<Button
android:layout_width="0dp"
android:layout_weight="1"
android:text="@string/category"
android:textSize="12dp"
style="@style/FlatButton"
android:id="@+id/toolbar_category_btn"
android:textColor="@android:color/white"
android:layout_height="wrap_content" />
<Button
android:layout_width="0dp"
android:layout_weight="1"
android:text="@string/filter"
android:id="@+id/toolbar_filter_btn"
android:textSize="12dp"
android:textColor="@android:color/white"
style="@style/FlatButton"
android:layout_height="wrap_content" />
</LinearLayout>
</android.support.v7.widget.Toolbar>
</android.support.design.widget.AppBarLayout>
推荐答案
您可以使用收拢工具栏布局来实现这一点。当你想要在滚动上折叠任何视图时,它是他们发布的材料设计UI组件之一。点击下面的链接了解它的工作原理,
https://www.journaldev.com/13927/android-collapsingtoolbarlayout-example
在示例中使用工具栏而不是Imageview。
这篇关于两个工具栏,只有第二个工具栏应该在坐标布局中滚动时折叠的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
织梦狗教程
本文标题为:两个工具栏,只有第二个工具栏应该在坐标布局中滚动时折叠
基础教程推荐
猜你喜欢
- AdMob 广告未在模拟器中显示 2022-01-01
- navigator.geolocation.getCurrentPosition 在 Android 浏览器上 2022-01-01
- Cocos2d iPhone 非矩形精灵触摸检测 2022-01-01
- Android:getLastKnownLocation(LocationManager.NETWORK_PROVIDER 2022-01-01
- 如何从 logcat 中删除旧数据? 2022-01-01
- NSString intValue 不能用于检索电话号码 2022-01-01
- iPhone - 获取给定地点/时区的当前日期和时间并将其与同一地点的另一个日期/时间进行比较的正确方法 2022-01-01
- 通过重定向链接在 Google Play 中打开应用 2022-01-01
- libGDX 从精灵或纹理中获取像素颜色 2022-01-01
- iOS4 创建后台定时器 2022-01-01
