2014-11-06 67 views
13

我想顯示和隱藏操作欄/工具欄作爲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://stackoverflow.com/a/30962301/1576416) – 2015-07-09 08:03:47

回答

5

看一看這樣的:

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