我有一個線性佈局我的ActivityGroup定義在Android的背景圖像不發生變化時,方向不
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:mtx="http://schemas.android.com/apk/res/com.matriksdata"
android:id="@+id/homeActivityGroupBG"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:background="@drawable/background">
,我有2背景繪項目位於「繪製」和「繪製土地」的文件夾。 當方向改變時,一切正常,但背景不會根據方向改變。它始終保持背景的第一個drawable。
我試圖通過將行手動改變它在onConfigurationChanged
方法:
background.setBackgroundResource(R.drawable.background);
它解決了上述問題。但是,每次配置更改或傳遞活動時,都會導致大量內存泄漏。
編輯:我創建一個theme.xml來定義窗口的背景圖像。 XML文件包含:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Theme" parent="android:Theme">
<item name="android:windowBackground">@drawable/background</item>
</style>
</resources>
我改變AndroidManifest.xml中作爲
<application android:icon="@drawable/icon" android:label="@string/app_name"
android:debuggable="true" android:name="com.matriksdata.app.DefaultApplication"
android:theme="@style/Theme">
和我刪除從我的佈局背景元素。沒有什麼改變。當設備方向改變時,我無法獲得新的可繪圖,並且最終導致應用程序崩潰的內存泄漏。
是否有任何其他方式強制改變drawables方向時呢?還是有任何理由,該應用程序使內存泄漏?
編輯:內存泄漏問題,我問了一個問題,在Android Memory Usage Problem on possibly using ActivityGroup
我相信它會起作用。您是否嘗試將縱向背景放在'drawable-port /'而不是'drawable /'中? – bigstones 2011-03-01 14:58:01
@我剛試過的大石頭,它沒有工作。 – Alkimake 2011-03-02 08:39:18