Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Define certain enter and exit transitions for specific views in activity

I am adding activity transitions using this documentation. I understand that I can define enter and exit transitions for the entire activity, such as explode.
However, what if I want to animate certain views of the entering activity differently? For example, if I have one view on the top half of the layout and one at the bottom of the layout, I may want to use a downwards slide transition on the top view and an upward slide animation on the bottom view. Is this possible to set?

I can think of using scene animations (documented here) and bringing in the elements from the sides of an empty view, but my layout is complicated and I am iterating it often, so keeping track of two different layouts for it is not really ideal.

Thanks!

like image 950
Timestretch Avatar asked Mar 01 '16 13:03

Timestretch


People also ask

What is transition animation in Android?

Android's transition framework allows you to animate all kinds of motion in your UI by simply providing the starting layout and the ending layout.

Which of the following transitions is a shared elements transition?

Android also supports these shared elements transitions: changeBounds - Animates the changes in layout bounds of target views. changeClipBounds - Animates the changes in clip bounds of target views. changeTransform - Animates the changes in scale and rotation of target views.

Is there a need for transitions in navigation explain your answer?

They help users orient themselves by expressing your app's hierarchy, using movement... Navigation transitions use motion to guide users between two screens in your app. They help users orient themselves by expressing your app's hierarchy, using movement to indicate how elements are related to one another.


1 Answers

Finally got it! The idea is to create custom transition in xml and to set there targets:

<?xml version="1.0" encoding="utf-8"?>
<transitionSet
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:transitionOrdering="together">
    <slide
        android:slideEdge="top">
        <targets>
            <target android:targetId="@id/toolbar"/>
        </targets>
    </slide>
    <slide
        android:slideEdge="bottom">
        <targets>
            <target android:targetId="@id/text"/>
        </targets>
    </slide>
</transitionSet>
like image 96
Kiryl Tkach Avatar answered Oct 01 '22 15:10

Kiryl Tkach