Between activity transitions, making the background fixed

284 Views Asked by At

I am currently working on an android project. I have a background xml file which is set as the windowBackground in styles.

My problem is, between activity transitions, background also slides with the screen. I want the background to be fixed, or in other terms freezed. So that, only the components on activites goes off screen or goes in by sliding.

This is my background xml,

<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item
        android:drawable="@drawable/background_image" />
    <item
        android:drawable="@drawable/vavien_logo"
        android:gravity="bottom|right"
        android:bottom="@dimen/normal_margin"
        android:right="@dimen/xlarge_margin"/>
</layer-list>

And this is how I make the transition between activites,

Intent intent = new Intent(LoginActivity.this, MeetingsActivity.class);
startActivity(intent);
overridePendingTransition(R.anim.enter_from_right, R.anim.exit_to_left);

Looking for a solution for my problem.

2

There are 2 best solutions below

0
BeepHawkins On

i think you could set this <item name="android:windowAnimationStyle">@null</item> in your style, it will disable the slide animation.

1
Mayank Bhatnagar On

Declare a style in your styles.xml

<resources>

    <style name="Theme.Background" parent="@style/Theme.AppCompat">
        <item name="android:windowBackground">@android:color/holo_blue_dark</item>
    </style>

</resources>

Then set this style as a theme to application element in manifest.xml

<application
        ...
        android:theme="@style/Theme.Background">

This way all the activities will have common background until it you override under any Activity element. Now when you switch between your activities then it will produce the same effect what you want.

Hope this helps.