简体   繁体   中英

Android - Animate views from Activity A in Activity B when minimum SDK is 16

Making a project I am faced with the following problem.

I have to perform some animations on views that belong to Activity A while at the same time perform animations that belong to Activity B.

Minimum SDK is 16 so I cannot use the Shared Elements approach.

The best approach I can think of is to start Activity B WITHOUT ANIMATION and create a mechanism that passes from Activity A to activity B instructions to create the necessary views dynamically, add them to the parent layout and perform the desired animations on all views.

Could someone share some insight about how to do something like that? My first thought was to pass a list of the InstanceState bundles for each view. something like

for(ViewReplicationData data:viewReplicationData){
    if(data.getViewClassName().equals("TextView"){
        TextView tv = new TextView(this);
        rootLayout.addView(tv);
        tv.onRestoreInstanceState(data.getInstanceState());
    }
}

Since everyone is providing solutions that work only for ImageViews let me be clear...I m talking about animating whole layouts that have TextViews, Buttons, ImageViews, ToggleButtons, CheckBoxes..everything.

Hope this is what you are looking for

https://github.com/lgvalle/Material-Animations

Thanks.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM