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 それが最も洗練されたソリューションではないことはわかっていますが、Android の違いが非常に多くのプラットフォームで処理するのがますます困難になっているため、可能な限りバリエーションを許可しない基本的な簡単なソリューションを使用する傾向があります。

于 2012-08-02T19:09:32.633 に答える
1

設定するlistviewwrap_content、黒い背景が表示されるため、リストビューの背景には特定のデバイスに固有のものがあります

于 2012-08-02T19:24:18.317 に答える
0

してみてください :

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