0

我有viewpager一堆,listviews当列表未满或为空时,我希望背景为黑色,特别motorola是在某些手机上,默认背景为灰色

这是我的带有 viewpager 的 xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:background="#000000">

<RelativeLayout android:id="@+id/top_rl"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@drawable/titlebg"
        android:layout_above="@+id/list">

         <ImageView
            android:id="@+id/imgStartupHeader"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:adjustViewBounds="true"
            android:scaleType="centerCrop"
            android:layout_alignParentTop="true"
            android:layout_alignParentLeft="true"
            android:layout_marginLeft="10dp"
            android:src="@drawable/logo"/>

         <ImageView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:adjustViewBounds="true"
            android:scaleType="centerCrop"
            android:layout_alignParentTop="true"
            android:layout_alignParentRight="true"
            android:layout_marginRight="10dp"
            android:src="@drawable/fire_android"/>
    </RelativeLayout>

<android.support.v4.view.ViewPager
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:id="@+id/pager"
    android:background="#000000"/>



</LinearLayout>    

以及保存列表视图的寻呼机 xml

<?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:id="@+id/layout"
android:background="#000000">


    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="fill_parent"
        android:layout_above="@+id/bottom_rl"
        android:background="#000000" >

    <ListView
        android:id="@android:id/list"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:background="#000000">

    </ListView>

    </RelativeLayout>

    <RelativeLayout android:id="@+id/bottom_rl"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:background="@drawable/bottombg">

    <ImageView android:id="@+id/listName"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true"
        android:src="@drawable/incidents"/>   
    </RelativeLayout>

</RelativeLayout>

在这两个文件中,我都将背景设置为,#000000但它仍然显示为灰色背景,我在这里缺少什么?

4

3 回答 3

1

而不是在背景中使用颜色,我必须使用具有我需要的颜色的可绘制对象 - 这样可以确保所有设备上的背景颜色都相同。不要忘记 android:scaleType="fitXY"

ps I know it's not the most elegant solution - but with Android differences becoming more and more difficult to handle accross so many platforms I tend to use basic easy solutions, that do not allow variations as much as possible.

于 2012-08-02T19:09:32.633 回答
1

Figured it out, if I set the listview to wrap_content it shows a black background so the listview background but have something specific to it on certain devices

于 2012-08-02T19:24:18.317 回答
0

请试试 :

android:background="#000000"
android:cacheColorHint="#000000"
于 2012-08-02T18:56:13.297 回答