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

问题描述:

我想显示和隐藏操作栏/工具栏作为Google Play商店应用程序。我在顶部使用滑动标签并查看分页器以显示每个标签的内容。这是谷歌Play商店应用的参考截图:滚动查看寻呼机内容时显示和隐藏操作栏

enter image description hereenter image description here

我的布局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> 

在此先感谢。

+0

看到这个[答案] (http://*.com/a/30962301/1576416) – 2015-07-09 08:03:47

看一看这样的:

https://github.com/flavienlaurent/NotBoringActionBar

这里还涉及到一个把戏。你需要:

  1. 列表视图裹布局
  2. 具有相同高度添加一个假头为你的动作条大标题
  3. 你的动作条重叠设置为true
  4. 翻译当列表移动时(即,假滚动条滚动时)的真实标题。

起初有点复杂,但一旦你明白了,就会明白它有多聪明和明显。链接将给你我需要的所有东西。

我自己使用该链接来实现它在我自己的应用程序,它的效果很好。

+0

我猜滚动视图也将工作。对? – mudit 2014-11-06 08:56:13

+0

我首先尝试使用滚动视图,但要使其工作起来真的很困难。滚动视图的问题在于你必须确保“假标题”能够自己正确翻译。使用listview,框架(即listview布局渲染器)会自动执行该操作,但无论如何都可以继续使用,如果它仍然不起作用,总会有listview选项:)。 – kha 2014-11-06 08:59:39

+0

谢谢!我会试试看。 – mudit 2014-11-06 10:09:02

结帐这个库:https://github.com/ksoichiro/Android-ObservableScrollView

这一定会帮助你

+0

这就是我正在寻找的! – 2015-07-28 09:16:33

检查这个例子中使用新的官方Android设计支持库来实现这一点:

https://github.com/chrisbanes/cheesesquare