简体   繁体   English

滚动查看寻呼机内容时显示和隐藏操作栏

[英]Show and hide Action bar while scrolling view pager content

I want to show and hide the action bar /toolbar as the Google Play store app. 我想将操作栏/工具栏显示并隐藏为Google Play商店应用。 I am using sliding tabs on top and view pager to show the content of each tab. 我在顶部使用滑动标签并查看寻呼机以显示每个标签的内容。 Here is the screenshot of Google play store app for the reference: 以下是Google Play商店应用的截图供参考:

在此输入图像描述在此输入图像描述

My layout XML : 我的布局XML:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent" android:layout_height="match_parent">

    <LinearLayout style="@style/HeaderBar"
        android:id="@+id/headerbar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical">

        <include layout="@layout/toolbar_no_bg"
            android:id="@+id/toolbar_actionbar"/>

        <com.fauzie.sample.tabsspinner.widget.SlidingTabLayout
            android:background="@color/tab_background"
            android:id="@+id/sliding_tabs"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" />
    </LinearLayout>

    <android.support.v4.view.ViewPager
        android:id="@+id/view_pager"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_below="@id/headerbar">

    </android.support.v4.view.ViewPager>

</RelativeLayout>

Thanks in advance. 提前致谢。

Have a look at this: 看看这个:

https://github.com/flavienlaurent/NotBoringActionBar https://github.com/flavienlaurent/NotBoringActionBar

There's a trick involved here. 这里有一个技巧。 You'll need to: 你需要:

  1. Wrap your layout in a list view 在列表视图中包装您的布局
  2. Add a fake header with the same height as your action bar large header 添加与操作栏大标题具有相同高度的假标题
  3. set your action bar overlay to true 将您的操作栏叠加设置为true
  4. Translate the real header when the list moves (ie when the fake header is scrolled). 列表移动时(即滚动假标题时)翻译真实标题。

It's a little bit complicated at first but once you understand it, you see how smart and obvious it all is. 一开始它有点复杂,但一旦你了解它,你就会发现它是多么聪明和明​​显。 The link will give you all you need I hope. 该链接将为您提供我所需要的一切。

I myself used that link to implement it in my own app and it works great. 我自己使用该链接在我自己的应用程序中实现它并且它工作得很好。

Checkout this library: https://github.com/ksoichiro/Android-ObservableScrollView 查看此库: https//github.com/ksoichiro/Android-ObservableScrollView

this will definitely help you 这肯定会对你有所帮助

Check this example to implement this with the new official Android Design Support Library: 检查此示例以使用新的官方Android设计支持库实现此功能:

https://github.com/chrisbanes/cheesesquare https://github.com/chrisbanes/cheesesquare

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在滚动时隐藏和显示操作栏? - how to hide and show action bar while scrolling? 我想在滚动Web视图时隐藏操作栏 - I want to hide Action Bar while scrolling the webview 向下滚动时隐藏名片视图,向上滚动时显示 - Hide card view while scrolling down and show when scrolling up 滚动视图寻呼机时,视频变为空白 - Video turns blank while scrolling view pager 如何在向下滚动时隐藏底部导航栏并在jetpack compose中向上滚动时显示它? - How to hide bottom navigation bar while scrolling down and show it while scrolling up in jetpack compose? 如何在Android中仅隐藏寻呼机选项卡(而不隐藏操作栏) - How to hide just the pager tabs (but not the action bar) in Android 隐藏/显示片段中的操作栏 - hide / show action bar in fragment 显示隐藏Sherlock动作栏 - Show Hide Sherlock Action Bar 在向上滚动时在ListView中显示Bottom Buttons Bar,在向下滚动时隐藏它 - Show Bottom Buttons Bar in ListView while scrolling up and hide when scrolling down 如何在滚动时显示视图并在Android中停止滚动后隐藏视图 - How to show view while scrolling and hide view after scrolling stop in android
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM