2014-02-05 56 views
0

我想在我的應用程序中重新創建此行爲。 Gmail和Google +有共同之處。查看哪些變成滾動頁面視圖(Gmail和Google +)

它是一個視圖,當滾動瀏覽信息的主體時會變成標題視圖。

它不是一個固定的視圖,如左圖所示,它在用戶開始滾動後變得固定。

有沒有人以前做過或有人可以推薦一種做法。

感謝

這裏有一個形象:

enter image description here

回答

0

你可以定義你的頭在單獨的XML文件格式。

像:header.xml現在

<merge xmlns:android="http://schemas.android.com/apk/res/android" > 
    <LinearLayout> 
    <!-- Contains all views as shown above in the image(ie Image of G,TextViews, Start Image, 
     BackImage, Menu Image) --> 
    </LinearLayout> 

</merge> 

,您可以包含這個頭你永遠在你的XML作爲頭想去的地方。 使用:

<include 
    android:id="@+id/include3" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    layout="@layout/header" /> 

例子:main_activity.xml

<LinearLayout> 

    <include 
     android:id="@+id/include3" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     layout="@layout/header" /> 

    <ScrollView 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" > 

     <LinearLayout> 
      <!-- Contains your remaining item or view of layout --> 
     </LinearLayout> 
    </ScrollView> 
</LinearLayout> 

我希望你在找什麼....

+0

您好,感謝您的答覆。上面的答案假定懸掛標題視圖之上沒有任何內容。如果你看到上面的圖片。您會注意到,該視圖上方還有一些其他信息(稍後會變成標題)。當您滾動瀏覽第一個視圖時,該部分內容會變成標題。 – AndroidEnthusiast