2012-02-18 10 views
1
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" 

    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:background="#FFFFFF" > 

    <LinearLayout 
     android:layout_width="590dp" 
     android:layout_height="wrap_content" 
     android:layout_gravity="center_horizontal" 
     android:orientation="vertical" > 
... 

下部のアクティビティ(ウィンドウ)に背景として画像を配置できますか?たとえば、ScrollViewをスクロールする場合、画像は常に下に表示されなければなりません。ImageViewをScrollViewの下に設定

答えて

1

RelativeLayoutsを試しましたか?次のようなものがあります:

<RelativeLayout android:width="fill_parent" 
android:height="fill_parent" 
...> 

    <WhateverYouWantAtBottom android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:layout_alignParentBottom="true" 
    /> 

    <ScrollView android:layout_width="fill_parent" 
    android:layout_height="wrap_content"> 
    <whateverYouWantScrollable android:layout_width="fill_parent" 
    android:layout_height="wrap_content"/> 
    </ScrollView> 

</RelativeLayout> 

あなたが望む画像で画像を見ることができます。スクロールビュー内のコンテンツの長さに関係なく、alignParentBottomがtrueに設定されている限り、画像ビューは下からずれることはありません。

編集:上記のコードでは、<whateverYouWantAtTheBottom>は最初に宣言したとおりにバックグラウンドになります。フォアグラウンドはXMLで最後に追加されたscrollViewの内容になります。

+0

ニース、しかし上にこのイメージ。これは、例えば、ScrollViewの下にありますか? –

+1

これは簡単です。バックグラウンドで何をしたいかは、まずXMLコードで宣言します。たとえば、スクロールビューをImageViewの上に配置する場合は、ImageViewコードを作成してからScrollViewコードを作成します。それを答えに加えてください。 – Urban

0

私はこれを試してみましたが、私のためにその作業

<?xml version="1.0" encoding="utf-8"?> 

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:orientation="vertical" > 

    <ImageView 
    android:id="@+id/imageView1" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:src="@drawable/ic_launcher" 
    android:layout_alignParentBottom="true" 
    /> 

<ScrollView 
    android:id="@+id/scrollView1" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:layout_above="@id/imageView1" > 



    </ScrollView> 



    </RelativeLayout> 
+0

しかし、あなたのスクロールビューがいっぱいであっても、あなたの画像ビューが重なっていなくても、このようになります。このようにして、画像は常に画面の下部に表示されます。この質問は、画像が背景にあることを求めました。下部の別のセクションではありません。 – Urban

+0

正確に彼が望むもの: – confucius

+0

彼はイメージを背景にしたいと思う – Urban

関連する問題