I have a linear layout for my ActivityGroup as defined
<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">
And i have 2 background drawables located in "drawable" and "drawable-land" folders. When orientation changes everything is normal but background is not changed according to orientation. It always keeps the very first drawable for background.
I tried to change it manually in onConfigurationChanged
method by adding the line:
background.setBackgroundResource(R.drawable.background);
it solves the problem. But it causes huge amount of memory leaks every time configuration changes or passing through activities.
Edit: I create a theme.xml to define background image to window. XML file contains:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Theme" parent="android:Theme">
<item name="android:windowBackground">@drawable/background</item>
</style>
</resources>
I changed AndroidManifest.xml as
<application android:icon="@drawable/icon" android:label="@string/app_name"
android:debuggable="true" android:name="com.matriksdata.app.DefaultApplication"
android:theme="@style/Theme">
and i removed background elements from my layouts. Simply nothing has changed. I can not get new drawable when device orientation changes and i get memory-leaks that causes application crashes eventually.
Is there any other way to force to change drawables when orientation does? Or is there any reason that the application makes memory-leaks ?
Edit : for memory leak problem i had asked a question at Android Memory Usage Problem on possibly using ActivityGroup