Scrollview和固定页脚对齐

时间:2014-06-26 20:54:16

标签: android scrollview footer

我有一个包含两个子元素的相对布局,一个ScrollView和RelativeLayout页脚。 ScrollView应该将屏幕分成两个相等的部分。在下半部分,ImageView应该直接位于固定页脚的上方。

在用户开始滚动之前,我无法让下半部分的ImageView直接位于页脚上方。如何让ImageView正确对齐?

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
 xmlns:tools="http://schemas.android.com/tools"
 android:layout_width="fill_parent"
 android:layout_height="fill_parent">
   <ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fillViewport="true" >
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
     android:orientation="vertical"
     android:layout_width="match_parent"
     android:weightSum="10"
     android:layout_height="0dp">

     <!-- 50% of screen-->
     <LinearLayout
      android:layout_width="match_parent"
      android:layout_height="0dp"
      android:layout_weight="5"
      android:id="@+id/gear_image_poster_container"
      android:orientation="vertical">
      <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent">
        <ImageView
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:scaleType="fitXY"
          android:adjustViewBounds="true"
          android:id="@+id/gear_detail_poster_image"/>
      </RelativeLayout>
     </LinearLayout>

  <!-- 50% of screen -->
  <LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="0dp"
    android:layout_weight="5"
    android:weightSum="6"
    android:layout_marginBottom="50dp"
    android:orientation="vertical">

    <TextView
        android:layout_width="fill_parent"
        android:layout_height="25dp"
        android:layout_weight="5"
        android:text="Trek Mens 13 Road Bike"
        android:textSize="25dp"
        android:maxLines="2"
        android:layout_marginRight="10dp"
        android:layout_marginLeft="10dp"
        android:paddingTop="0dp"
        android:id="@+id/gear_detail_title"/>
    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:paddingTop="0dp"
        android:paddingLeft="10dp"
        android:weightSum="2"
        android:layout_weight="1"
        android:orientation="horizontal">
      <ImageView
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_gravity="left"
            android:layout_weight="1"
            android:id="@+id/owner_picture"
            android:layout_alignParentEnd="false"
            android:layout_alignParentStart="true" />
    </RelativeLayout>
  </LinearLayout>
  <TextView
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_marginRight="10dp"
    android:layout_marginLeft="10dp"
    android:layout_marginBottom="50dp"
    android:textSize="18dp"
    android:text="I should be under the fixed footer"/>
  </LinearLayout>
 </ScrollView>

 <!--Fixed Footer -->
 <RelativeLayout
    android:id="@+id/footer"
    android:layout_width="fill_parent"
    android:layout_height="50dp"
    android:background="#97c51017"
    android:layout_alignParentBottom="true"/>
</RelativeLayout>

0 个答案:

没有答案
相关问题