2012-02-18 4 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" > 
... 

Puis-je placer l'image comme arrière-plan dans le fond Activité (fenêtre)? Par exemple, lors du défilement de ScrollView, l'image doit toujours être en bas et visible.définir ImageView sous un ScrollView

Répondre

1

Avez-vous essayé d'utiliser RelativeLayouts? Quelque chose comme:

<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> 

En bas, vous pourriez avoir une image avec l'image que vous vouliez. Quelle que soit la durée de votre contenu dans le scrollview, l'imageview ne bougera pas du bas tant que le paramètre alignParentBottom est défini sur true.

EDIT: Dans le code ci-dessus, le <whateverYouWantAtTheBottom> sera en arrière-plan comme je l'ai déclaré en premier. Le premier plan sera le contenu du scrollView tel qu'il a été ajouté en dernier dans le fichier XML.

+0

Nice, mais cette image sur le dessus. Est-ce que ci-dessous, par exemple, ScrollView? –

+1

C'est facile. Tout ce que vous voulez en arrière-plan, déclarez-le d'abord dans votre code XML. Par exemple, si vous voulez que le scrollview soit au-dessus de l'ImageView, alors écrivez d'abord votre code ImageView, puis votre code ScrollView. Je rajoute ça dans la réponse. – Urban

0

J'ai essayé et son travail pour moi

<?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

Mais de cette façon, si votre scrollview est plein, même alors il ne chevauchera pas votre imageview. De cette façon, l'image prendra toujours la partie inférieure de l'écran. La question demandait que l'image soit à l'arrière-plan, pas comme une section distincte en bas. – Urban

+0

c'est exactement ce qu'il veut :) – confucius

+0

Je pense qu'il veut faire de l'image pour être à l'arrière-plan ... – Urban

Questions connexes