0

ImageView の src として次の画像があります。これを背景画像として使用します。これにより、アプリケーションのメモリが最大 5MB から最大 20M に増加します。

ここに画像の説明を入力

これは、この画像を使用するコードです: (android:id="@+id/listViewBackground" は、私が話しているイメージビューです)

    <RelativeLayout
    android:id="@+id/ContentLayout"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_below="@id/ButtonsMenu"
    android:background="@android:color/transparent" >

    <ImageView
        android:id="@+id/listViewBackground"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="@android:color/transparent"
        android:scaleType="center"            
        android:src="@drawable/background" />

    <LinearLayout
        android:id="@+id/header"
        android:layout_width="fill_parent"
        android:layout_height="50dp"
        android:background="@android:color/transparent" >

        <TextView
            android:id="@+id/leftHeader"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:background="@drawable/button_green"
            android:gravity="center"
            android:text="@string/Title_BatteryLevel"
            android:textColor="@android:color/white" />

        <TextView
            android:id="@+id/rightHeader"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:background="@drawable/button_blue"
            android:gravity="center"
            android:text="@string/Title_Duration"
            android:textColor="@android:color/white" />
    </LinearLayout>

    <LinearLayout
        android:id="@+id/AdLayout"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:background="@android:color/transparent" >
    </LinearLayout>

    <ListView
        android:id="@+id/listView"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_above="@id/AdLayout"
        android:layout_below="@id/header"
        android:background="@android:color/transparent"
        android:cacheColorHint="#00000000"
        android:clickable="false"
        android:focusable="false"
        android:focusableInTouchMode="false"
        android:listSelector="@android:color/transparent"
        android:paddingBottom="5dp" >
    </ListView>
</RelativeLayout>

この画像は、さまざまな画面サイズに対応する必要があるため、高解像度です。ラインも見えるようにしたいです。

アプリが使用するメモリを減らすにはどうすればよいですか?

4

1 に答える 1

2

まず、画像を繰り返し可能な部分だけに切り詰めます。

次に、背景画像をビューに適用する方法に関するこのチュートリアルに従ってください (この場合は、相対レイアウト "listViewBackground" ) http://androidforbeginners.blogspot.com/2010/06/how-to-tile-background-image- in-android.html

于 2012-06-19T17:55:54.087 に答える