Android,使大背景图像可滚动

Android,使大背景图像可滚动,android,xml,Android,Xml,我正在制作一个android应用程序,我想设置一个大图像作为背景。但是,我只希望在启动时显示此图像的一小部分,并且我希望能够滚动到图像的其余部分(通过滑动) 这就是我目前所拥有的 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent"

我正在制作一个android应用程序,我想设置一个大图像作为背景。但是,我只希望在启动时显示此图像的一小部分,并且我希望能够滚动到图像的其余部分(通过滑动)

这就是我目前所拥有的

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    android:background="@drawable/background"

     >


    <ImageButton
        android:id="@+id/searchbutton"
        android:contentDescription="@null"
        android:scaleType="fitXY"
        android:layout_height="50dp"
        android:layout_width="55dp"
        android:layout_gravity="left"
        android:onClick="searchmethod"
        android:src="@drawable/search" />

    <ImageButton
        android:id="@+id/filterbutton"
        android:scaleType="fitXY"
        android:contentDescription="@null"
        android:state_pressed="true" android:drawable="@drawable/search"
        android:layout_height="50dp"
        android:layout_width="55dp"
        android:layout_alignParentRight="true"
        android:layout_alignTop="@+id/searchbutton"
        android:onClick="choosefilter"
        android:src="@drawable/filter" />

    <ImageButton
        android:id="@+id/Zoomoutbutton"
        android:contentDescription="@null"
        style="?android:attr/buttonStyleSmall"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_alignRight="@+id/filterbutton"
        android:layout_marginBottom="27dp"
        android:src="@drawable/zoomout"
         />

    <ImageButton
        android:id="@+id/Zoominbutton"
        android:contentDescription="@null"
        style="?android:attr/buttonStyleSmall"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignTop="@+id/Zoomoutbutton"
        android:layout_toLeftOf="@+id/Zoomoutbutton"
        android:src="@drawable/zoomin"
         />

</RelativeLayout>

不过,这只是在背景中显示整个图像,而我希望显示其中的一小部分,然后在其上滚动。如果已经有人问过这个问题,我很抱歉,但是我找不到任何对我有帮助的答案


编辑:好的,我现在可以滚动图像了,但我希望我的按钮一直留在屏幕的角落里。有人能帮忙吗?当前,当我滚动时,我正在从按钮处滚动。

在滚动视图中嵌入RelativeLayout。您没有指定垂直或水平,因此可能需要水平滚动视图(或两者都需要?

您需要使用一个滚动视图对象来保存图像。ScrollView尺寸可以由您设置,然后图像的其余部分可以滚动。

好的,非常感谢你们两位。但我有两个问题。1.我需要有一个水平和垂直的卷轴,那么我是否要将这两个视图嵌入到彼此中?如果是,尺寸是如何工作的?2.如何始终将图标固定在屏幕的某个部分?