2013-06-19 34 views
0

我有一個工作任務來創建顯示項目列表的視圖,並且它由選項卡控制。列表頂部必須有一個顯示圖像的標題。標籤需要位於標題圖片下方。用戶滾動標籤時,標題圖像向上移動,直至標題消失。選項卡絕對不應該出現在屏幕上,它們應始終粘貼在列表視圖的頂部,以便用戶在3個列表之間導航。熱切實現Google+個人資料列表視圖佈局?

我在google +個人資料視圖中發現了類似的內容。該圖像顯示了它應該如何的一個示例。劑量任何人都知道如何在Android上實現。 https://dl.dropboxusercontent.com/u/81459779/question.jpg

回答

0

檢查Action Bar Sherlock。安裝「ABS:Demos」應用程序並查找「Tab Navigation」示例並嘗試使用它。

UPDATE

哦,我知道了...

所以,儘量用 「ABS:碎片」 的應用程序。這裏有一個名爲「Tabs」的例子。

如果你看到它的佈局(fragment_tabs.xml),你可以看到每個部件。您可以將TabHost換成新的LinearLayout,然後在TabHost之上加上View

更改此:

<TabHost 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@android:id/tabhost" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 

    <LinearLayout 
     android:orientation="vertical" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent"> 

    <TabWidget 
     android:id="@android:id/tabs" 
     android:orientation="horizontal" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_weight="0"/> 

    <FrameLayout 
     android:id="@android:id/tabcontent" 
     android:layout_width="0dp" 
     android:layout_height="0dp" 
     android:layout_weight="0"/> 

    <FrameLayout 
     android:id="@+android:id/realtabcontent" 
     android:layout_width="match_parent" 
     android:layout_height="0dp" 
     android:layout_weight="1"/> 

</LinearLayout> 

這樣的事情:

<LinearLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:orientation="vertical" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 

    <TextView 
     android:id="@+id/Hello" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="CHANGE ME FOR THE VIEW YOU WANT" /> 

    <TabHost 
     android:id="@android:id/tabhost" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent"> 

     <LinearLayout 
      android:orientation="vertical" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent"> 

      <TabWidget 
       android:id="@android:id/tabs" 
       android:orientation="horizontal" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:layout_weight="0"/> 

      <FrameLayout 
       android:id="@android:id/tabcontent" 
       android:layout_width="0dp" 
       android:layout_height="0dp" 
       android:layout_weight="0"/> 

      <FrameLayout 
       android:id="@+android:id/realtabcontent" 
       android:layout_width="match_parent" 
       android:layout_height="0dp" 
       android:layout_weight="1"/> 

     </LinearLayout> 
    </TabHost> 

+0

泰快速的答案。我知道這個例子,它很容易實現。問題是我需要上面的標籤圖片標題和標籤需要向上滾動,直到他們到達頂部,然後堅持在那裏。 – MarkoMilos

+0

添加了更新。 –

+0

好吧,讓我說,我把標籤內容與一些項目列表視圖。我想要達到的目標是:當用戶滾動列表時,您命名爲「爲我所需的視圖改變我」的textView應該離開屏幕。當用戶一直向下滾動時,它應該回來。 – MarkoMilos