What view structure is used in the Google Plus Android app for the photo and comment scrolling?
I am referring to the photo detail view where it looks like
Google+ header
---------
Photo
transparent background meta data (user, description, etc)
comments
---------
Add comment text input that is always on screen bottom
The Photo, transparent background meta data, and comments all scroll while the Add comment text input remains fixed at the bottom of the screen.
Is this just aListView
wi开发者_C百科th a special zooming ImageView
that has the photo size set at runtime?This is done with an RelativeLayout. Inside of a RelativeLayout you can place your views wherever you want. In this case you stick the Google Plus header to the parents top and the comment bar to the parent's bottom. In between of this both views you put a ScrollView, which containes the image, the meta tags and the comments to the photo.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView
android:id="@+id/actionbar"
android:layout_width="fill_parent"
android:layout_height="50dp"
android:layout_alignParentTop="true"
android:textSize="20dp"
android:text="Google Plus ActionBar" />
<TextView
android:id="@+id/commentbar"
android:layout_width="fill_parent"
android:layout_height="50dp"
android:layout_alignParentBottom="true"
android:textSize="20dp"
android:text="Add Comment Bar" />
<ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_below="@id/actionbar"
android:layout_above="@id/commentbar">
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<FrameLayout
android:layout_width="fill_parent"
android:layout_height="500dp"
android:background="#00ff00" />
<FrameLayout
android:layout_width="fill_parent"
android:layout_height="50dp"
android:background="#0000ff" />
<FrameLayout
android:layout_width="fill_parent"
android:layout_height="50dp"
android:background="#ff0000" />
</LinearLayout>
</ScrollView>
result (green view should represent the image, the blue and the red view the comments):
精彩评论