Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/189.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 具有背景图像的ListView_Android_Image_Listview - Fatal编程技术网

Android 具有背景图像的ListView

Android 具有背景图像的ListView,android,image,listview,Android,Image,Listview,我想有一个图像作为listview的背景。 每个项目没有一个,但对于所有项目,并且不会随着listview的移动而移动。 我该怎么做呢?我会这样做: <RelativeLayout android:layout_width="fill_parent" android:layout_height="fill_parent"> <ImageView android:layout_width="fill_parent" andr

我想有一个图像作为listview的背景。 每个项目没有一个,但对于所有项目,并且不会随着listview的移动而移动。
我该怎么做呢?

我会这样做:

<RelativeLayout
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">
    <ImageView
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:src="@drawable/the_background_image"/>
    <ListView
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:cacheColorHint="#00000000"/>
</RelativeLayout>

我用过这个:

<ListView 
    android:id="@android:id/list"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_below="@id/lists_header"
    android:layout_marginLeft="6dip"
    android:layout_marginRight="6dip"
    android:divider="@drawable/list_divider"
    android:dividerHeight="2dip"
    android:cacheColorHint="@color/shopper_background"
    android:background="@drawable/paper_frame" />

其中,纸框是一个9.5英寸的可拉制面片

这提供了一个(拉伸以填充ListView区域)固定的背景图像,该图像不会随列表滚动,这可能是您正在尝试做的


我想将图像拉伸到列表的高度(即,如果列表很长,顶部和/或底部可能会离开屏幕),我正在寻找如何做到这一点。

我尝试为顶部元素提供背景,但它无法正常工作。这确实很有魅力。谢谢