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

我可以将图像作为背景放在底部Activity(窗口)中吗?例如,当滚动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> 

在底部,你可以有你想要的图像的ImageView的。无论滚动视图中的内容多长时间,只要将alignParentBottom设置为true,imageview就不会从底部移出。

编辑:在上面的代码中,<whateverYouWantAtTheBottom>将在我首先声明它的背景中。前景将是scrollView的内容,就像在XML中最后添加的那样。

+0

不错,但在上面这个图片。这可以在下面,例如,ScrollView? – 2012-02-18 22:52:21

+1

很简单。无论您在后台需要什么,首先在您的XML代码中声明。例如,如果您希望scrollview位于ImageView上方,请首先编写您的ImageView代码,然后再编写您的ScrollView代码。我在答案中补充说。 – Urban 2012-02-19 10:07:32

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

但这种方式如果你的滚动视图已满,即使它不会重叠你的imageview。这样图像将始终占据屏幕的底部。问题要求图片在背景中,而不是作为底部的单独部分。 – Urban 2012-02-18 22:35:56

+0

多数民众赞成正是他想要的:) – confucius 2012-02-18 22:37:32

+0

我想他想要在背景图像... – Urban 2012-02-18 22:39:00