android listactivity背景颜色

Bru*_*eri 2 android background-color listactivity

如何设置列表活动的背景颜色?我可以设置列表视图项的背景颜色,但不能设置活动视图的孔(请参见图像底部的黑色部分).我怎样才能做到这一点?

ListActivity XML如下所示:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="horizontal"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:padding="5dp"
    android:background="@color/darkbluelogo" >

    <ImageView android:id="@+id/list_image"
        android:layout_width="48dip"
        android:layout_height="48dip"
        android:contentDescription="@id/list_image"
         />
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:orientation="vertical"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:padding="5dp" 
        android:background="@color/darkbluelogo"
        android:scrollingCache="false" 
        android:cacheColorHint="#00000000" >

        <TextView
            android:id="@+id/title"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:text="@+id/title" >
        </TextView>

        <TextView
            android:id="@+id/datetime"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:text="@+id/datetime" >
        </TextView>

    </LinearLayout>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)

这就是它在设备上的显示方式: 在此输入图像描述

解:

我必须添加样式XML并将其添加到AndroidManifest.xml中的活动

这是正确答案:https: //stackoverflow.com/a/10426474/1306012

Akr*_*ram 6

设置layout_heightfill_parent包含listview的xml文件.并根据需要设置该xml文件的背景.

编辑:在这种情况下,您可以使用主题设置背景

像这样

<style name="MyTheme">

    <item name="android:background">@color/darkbluelogo</item>

</style>
Run Code Online (Sandbox Code Playgroud)

并将此主题应用于清单文件中的列表活动.

    <activity
        android:theme="MyTheme"
Run Code Online (Sandbox Code Playgroud)