2011-07-19 8 views
1

固定フッターを持つAndroidレイアウトを作成しようとしていますが、残りの領域はScollViewで占めています。 ScrollViewの一番下に固定されていて、ScrollViewの背後に固定されている(そして内容がスクロールされている)2番目の「フッター」が必要です。 )visual exampleです。2番目の固定フッターをScrollViewの下にレイアウトするにはどうすればよいですか?

私はRelativeLayout methodを使って固定フッターを作成しても機能しますが、それが占めるスペースは画面全体のサイズから削除されていないようです。私は一見無限の方法の組み合わせのように見えるものを試しました。そして、私は働くものを考え出すことができません。

ここでは私が取り組んできたことがあります。

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:gravity="top" android:layout_height="fill_parent" android:layout_width="fill_parent" android:background="@drawable/background_image" android:orientation="vertical"> 
<ScrollView android:layout_width="fill_parent" android:layout_height="fill_parent" android:gravity="fill" android:layout_weight="1"> 
    <FrameLayout android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="1"> 
     <ImageView android:layout_centerHorizontal="true" android:layout_width="fill_parent" android:layout_height="wrap_content" android:src="@drawable/scroll_footer_image" android:layout_gravity="bottom" android:layout_weight="1"></ImageView> 
     <LinearLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="vertical" android:layout_weight="1"> 
      <!-- content for the scrollview goes here. --> 
     </LinearLayout> 
    </FrameLayout> 
</ScrollView> 
<RelativeLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:background="@drawable/footer_background_image" android:layout_alignParentBottom="true"> 
    <ImageView android:scaleType="centerInside" android:layout_gravity="center" android:clickable="false" android:src="@drawable/footer_contents" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_centerInParent="true" android:layout_centerHorizontal="true" android:layout_centerVertical="true" android:layout_weight="0"></ImageView> 
</RelativeLayout> 
</LinearLayout> 
+0

私は1つの可能な解決策を思いついてきました。私が取り組んでいる固定フッターはイメージに基づいているので、スクロールフッターに空のスペースを追加しました。スクロールフッターイメージとその中のスクロールビューを持つFrameLayoutと、固定フッターのための別々のLinearLayoutがすべてRelativeLayoutにラップされています。私はそのような画像を操作する大きなファンではないので、そこに他のソリューションがあるかどうかを確認することはまだ興味があります。 – Mark

+0

ああ、その解決策はFrameLayoutを離れて、固定フッターの後ろに座っているScrollViewが読めないコンテンツを残してしまいます。 – Mark

答えて

1

[OK]ので、最終的に答えは、android:layout_gravityとandroid:layout_weightを使用するように見えます。これは私のためのトリックを行うように見えますが、画像に余白はありません。

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_height="fill_parent" android:layout_width="fill_parent" android:background="@drawable/background_image" android:orientation="vertical"> 
<FrameLayout android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="1" android:layout_gravity="fill"> 
    <ImageView android:src="@drawable/scroll_footer_image" android:layout_width="fill_parent" android:layout_height="wrap_content" android:gravity="bottom" android:layout_gravity="bottom"/> 
    <ScrollView android:fillViewport="true" android:layout_width="fill_parent" android:layout_height="fill_parent"> 
     <LinearLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="vertical"> 
      <!-- additional content goes here --> 
     </LinearLayout> 
    </ScrollView> 
</FrameLayout> 

<LinearLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="vertical" android:layout_weight="0" android:gravity="bottom"> 
    <LinearLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:background="@drawable/footer_topper_image" android:orientation="vertical"/> 
    <LinearLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:background="@drawable/footer_background_image" android:orientation="vertical" android:gravity="center"> 
     <ImageView android:src="@drawable/footer_contents" android:layout_width="wrap_content" android:layout_height="wrap_content"></ImageView> 
    </LinearLayout> 
</LinearLayout> 

関連する問題