2014-02-05 58 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