0

let's see if someone can help me with this.

In my app I have successfully implemented slide transitions between most of my activities. All my activities layouts consist in a regular toolbar and some content below. So what I would like is the animations to ignore the toolbar and only affect the main content.

Ideally, the toolbar would remain in its place and the main content of the layout would be the one sliding.

For completion of the question, here is one of my transition xmls:

<?xml version="1.0" encoding="utf-8"?>

<translate
    android:duration="500"
    android:fromXDelta="100%"
    android:toXDelta="0%" >
</translate>

and this is the way I'm setting transitions:

overridePendingTransition(R.transition.out, R.transition.in);

Thanks

Andrii Omelchenko
  • 13,183
  • 12
  • 43
  • 79
Nemesis
  • 1,138
  • 1
  • 14
  • 29

3 Answers3

2

Alright, so I found the answer after some hours working on it. I'm having some issues in android 7.1. Other than that, it works in 5.x and 6.x

<?xml version="1.0" encoding="utf-8"?>
<slide
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:slideEdge="right"
    android:duration="500">
    <targets>
        <target android:excludeId="@id/toolbar"/>
        <target android:excludeId="@android:id/statusBarBackground"/>
        <target android:excludeId="@android:id/navigationBarBackground"/>
    </targets>
</slide>

As you can see, you can add views to be ignored by the animation. In my case, the toolbar, status and navigation bar.

Then you can apply the animation the way you prefer, it will affect everything but the elements specified to be ignored.

Nemesis
  • 1,138
  • 1
  • 14
  • 29
1

My suggestion is to make a single activity containg toolbar and a container layout, and place fragments inside container and do transition for fragments. It may solve your problem.

Nivedh
  • 971
  • 1
  • 8
  • 19
  • Hi Nivedh, I've thought of that possibility, which I know it's doable. But I know that doing it through activities is also possible, I just don't know how. Thanks for the suggestion though. – Nemesis Nov 07 '16 at 09:38
  • Yes I also thin its doable, I suggested a simple method . Please go through http://stackoverflow.com/questions/27658577/how-can-i-exclude-actionbar-when-transitions-between-activities-on-android-5-0 – Nivedh Nov 07 '16 at 09:41
  • Hi Nivedh, thanks for pointing out the other post, I got it working thanks to it – Nemesis Nov 07 '16 at 15:04
-1

try adding below code in your style. See if it works

<style name="your_theme_name" parent="your_theme">
<item name="android:windowActionBarOverlay">true</item>
</style>
Kunal Parikh
  • 463
  • 4
  • 15