lgvalle / material-animations Goto Github PK
View Code? Open in Web Editor NEWAndroid Transition animations explanation with examples.
License: MIT License
Android Transition animations explanation with examples.
License: MIT License
I want to show Animate shared elements in transitions between fragments, but find no samples. How to make it? Thank u
I managed to get it to build in Android Studio 2023.3.1. Took most of an afternoon and many tears.
Seems to mostly work properly up to SDK 34. I may also have fixed a crash.
It's a nice-looking app!
Find a diff attached.
Material-Animations.diff.zip
I am hoping you can point me in the right direction, no specifics needed...
How do I do the animation show in Design Spec - Navigational Transitions, Animation of parent-to-child transition where the calendar stays underneath the fragment.
Say I have Activity A and activity B. B has 'slide' set as the enter animation.
I would like to slide B on top of A where A will remain untouched until animation completes and B is completely visible.
Is that possible at all? In reality, when I try to do it Activity A disappears which leaves a blank screen and on top of that blank screen Activity B slides in
@lgvalle i use "@BindingAdapter("android:colorTint")" and "android:colorTint"
the result is the ImageView can`t change color.
I have a view that has a button,and 4 imageview. I want the 4 imageviews do Explode transition but I dont want the button do Explode. how to do ?
I have a doubt that the below code need to set before setContentView.
getWindow().setExitTransition(mExplode);
but after setContentView, I get the view id.
then use this code to setTransition.
mExplode.addTarget(mImgRl);
hope your reply !
sincerely
I want to learn
Hi,
I am trying to run your project on a JellyBean emulator, and it crashes with
java.lang.NoClassDefFoundError: android.transition.Explode
My question is, is it possible to make this stuff run on pre-Lollipop devices?
I have an issue about "@BindingAdapter".
In project,has a line as "@BindingAdapter("bind:colorTint")",and every time I build the project AS would throw a wrong like "Error:(23, 24) ่ญฆๅ: Application namespace for attribute bind:colorTint will be ignored".
Although the project can run,but I am not happy with it.
So I change that line code to "@BindingAdapter("android:colorTint")",then change "app:colorTint" to "android:colorTint".or just change "@BindingAdapter("bind:colorTint")" to "@BindingAdapter("colorTint")",now AS never throw that wrong again.
Could you tell me why?
For the "Circular Reveal from the middle of target view" and "Circular Reveal from top of target view + animations" examples towards the bottom of the guide, it looks like someone accidentally swapped the lines for calculating the int "cy" variable.
"Circular Reveal from the middle of target view" -> int cy = viewRoot.getTop();
"Circular Reveal from top of target view + animations" -> int cy = (viewRoot.getTop() + viewRoot.getBottom()) / 2;
I'm using shared element transition and its working well, but only in forward direction. When I press back arrow in the action bar (not the back button), there is no reverse transition of the shared transition.
Although this works when you press the back button.
Any help ?
Fragment fragment = ViewerFragment.newInstance(diary.getPhotoUrl());
fragment.setSharedElementEnterTransition(new ChangeBounds());
getFragmentManager().beginTransaction()
.hide(this)//either using hide or not won't work
.add(R.id.container, fragment)// it work when using replace
.addToBackStack("")
.addSharedElement(attachPicture, attachPicture.getTransitionName())
.commit();
Could you tell me why is that? Because I read the document of addSharedElement
, it says:
Used with custom Transitions to map a View from a removed or hidden Fragment to a View from a shown or added Fragment.
Hello dear
Please help me.
I am not find derectory com.lgvalle.material_animations.databinding
and class related to databinding like (ActivitySharedelementBinding)
I am trying to use shared element animation in my project and I am using support library for fragments.
I tried the same procedure to add shared element animation but it is not working.
I tested the code on Android 6.0
If I write this code like tutorial:
Fade fade = TransitionInflater.from(this).inflateTransition(R.transition.activity_fade); getWindow().setEnterTransition(fade);
Androd give me Incompatible types. So I tried:
Transition fade = TransitionInflater.from(this).inflateTransition(R.transition.activity_fade);
getWindow().setEnterTransition(fade);
and same for Activity B. This dont generate error, but it doesn't work
Hi!
In example You show explode transition as enter transition, but reverse transition is slide.
How I can set explode transition as return or exit?
When I call setExitTransition(explodeTransition) or setReturnTransition(explodeTransition)
it not take any effect. I want explode as exit or return transition (up part slide up and down screen part slide down), reverse as enter.
Thank You!
Great Library! it would be great if someone can publish it on Maven or @lgvalle Please make Github Release to be use with jitpack.
Thanks.
hi, is it possible that i run these nice animations on Android 4.0 or versions before?
I just want to try it out without having to haul in so much code by myself, would appreciate if I could do that if it was a one-liner to do so, just like all the android libs out there. Great work by the way, it looks very ..rigorous :)
I'm doing this,it is not working for me,any pointers guys
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
setEnterTransition();
setExitTransition();
}
@TargetApi(21)
private void setEnterTransition(){
Fade fade_transition = new Fade();
fade_transition.setDuration(1000);
getWindow().setEnterTransition(fade_transition);
}
@TargetApi(21)
private void setExitTransition(){
Slide slide_transition = new Slide();
slide_transition.setDuration(1000);
getWindow().setExitTransition(slide_transition);
}
I have a ListView with a custom adapter that loads images and text. How would I be able to utilize the "Shared elements between Activities" when clicking on each of the items? I'm confused because if you click on an item, then set the transition effect to animate the ImageView, won't all of the images be animated rather than the one that corresponds with the item row you have clicked?
If you could give an example, that would be extremely helpful. Thank you.
Hello,
First of all, thanks for this useful code!
I've found that the listeners set to enterTransition and returnTransition in DetailActivity3#setupEnterAnimations() and DetailActivity3#setupExitAnimations() are both called when DetailActivity3 starts and also when back is pressed.
In fact, returnTransition is called first.
Using your layout no problem were observed, but using a different layout (more complex) or concatenating different effects may cause problems, for example when setting the visibility/invisibility of the child views.
The only solution I've found is to call setupExitAnimations() when enterTransition ends:
final Transition enterTransition = getWindow().getSharedElementEnterTransition();
enterTransition.addListener(new Transition.TransitionListener() {
...
@Override
public void onTransitionEnd(Transition transition) {
animateRevealShow(bgViewGroup);
enterTransition.removeListener(this);
setupExitAnimations();
}
...
});
Have you ever faced this situation?
i am tring to make transition ShareElement circle to Square like whatsapp but its not going as well. Could you provide demo for that?
Which all new material transition animations are possible in fragment transition for API-level 14 to latest.
Not an issue - wrongly filed into GitHub
I'm so sorry for this quastion. Which android versions supported? Is it work fine on lower version such as 4 ?
Thanks
I do it it like this in my BasicActivity onCreate():
getWindow().requestFeature(Window.FEATURE_CONTENT_TRANSITIONS);
setupWindowAnimations();
super.setContentView(R.layout.layout_base);
setContentView(getContentViewID());
My setupWindowAnimations() function like this:
protected void setupWindowAnimations() {
L.i("setupWindowAnimations");
Slide slide = (Slide) TransitionInflater.from(this).inflateTransition(R.transition.activity_slide_out);
Fade fade = (Fade) TransitionInflater.from(this).inflateTransition(R.transition.activity_fade_in);
getWindow().setEnterTransition(slide);
getWindow().setExitTransition(fade);
}
when I call startActivity(A,B), the animations not worked.Can u help me? Thanks a lot!
Sorry was just getting introduced to databinding. Just found out the classes get generated at compile time and are related to the layout file names.
How to add shared element between text in listview and text in next activity?
Can someone tell me why I went into an activity where the background color was the same as the ball color?
Whrn i Prove thsi transcations with Android 6 I have a problem whrn back to activity A(with stat activity again, not with back button) I can't touch anything I have thsi warning n=0, id[0]=0, x[0]=827.0, y[0]=1133.0, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=0, eventTime=303259760, downTime=303259642, deviceId=4, source=0x1002 }
12-09 16:28:18.831 6865-6865/ad.andorratelecom.my_andorra_telecom
Only with Android 6 in Android 5 works fine
Can splashscreen (activity layout A) slide up to loginscreen(activity layout B)?
Intent i = new Intent(MainActivity.this, SharedElementActivity.class);
View sharedView = blueIconImageView;
String transitionName = getString(R.string.blue_name);
ActivityOptions transitionActivityOptions = ActivityOptions.makeSceneTransitionAnimation(MainActivity.this, sharedView, transitionName);
startActivity(i, transitionActivityOptions.toBundle());
What is blueIconImageView. How can I create it?
Is that have some demos for android 4.x ? I wanna add this to my App but it`s not for android API which is before android Lollipe
I have 2 questions, if it's ok to ask:
Hi i am getting following exception in logcat when i import and run this project
05-23 09:45:56.073: E/AndroidRuntime(480): FATAL EXCEPTION: main
05-23 09:45:56.073: E/AndroidRuntime(480): java.lang.NoClassDefFoundError: android.transition.Explode
05-23 09:45:56.073: E/AndroidRuntime(480): at com.lgvalle.material_animations.MainActivity.setupWindowAnimations(MainActivity.java:36)
05-23 09:45:56.073: E/AndroidRuntime(480): at com.lgvalle.material_animations.MainActivity.onCreate(MainActivity.java:31)
05-23 09:45:56.073: E/AndroidRuntime(480): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1048)
05-23 09:45:56.073: E/AndroidRuntime(480): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1712)
05-23 09:45:56.073: E/AndroidRuntime(480): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1764)
05-23 09:45:56.073: E/AndroidRuntime(480): at android.app.ActivityThread.access$1500(ActivityThread.java:122)
05-23 09:45:56.073: E/AndroidRuntime(480): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1002)
05-23 09:45:56.073: E/AndroidRuntime(480): at android.os.Handler.dispatchMessage(Handler.java:99)
05-23 09:45:56.073: E/AndroidRuntime(480): at android.os.Looper.loop(Looper.java:132)
05-23 09:45:56.073: E/AndroidRuntime(480): at android.app.ActivityThread.main(ActivityThread.java:4025)
05-23 09:45:56.073: E/AndroidRuntime(480): at java.lang.reflect.Method.invokeNative(Native Method)
05-23 09:45:56.073: E/AndroidRuntime(480): at java.lang.reflect.Method.invoke(Method.java:491)
05-23 09:45:56.073: E/AndroidRuntime(480): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:841)
05-23 09:45:56.073: E/AndroidRuntime(480): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599)
05-23 09:45:56.073: E/AndroidRuntime(480): at dalvik.system.NativeStart.main(Native Method)
where is the databinding folder in this project?
when I run the app, stopped and logcat errors:
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.lgvalle.material_animations/com.lgvalle.material_animations.MainActivity}: java.lang.IllegalArgumentException: Invalid slide direction
how to use this codes on SDK 14+ ?
I want to have an activity. the activity has 3 tabs. each tab contain a fragment. the fragment contains list. when i click on a list item it will start an activity. how do i animate this and how to do the reverse animation. please do suggest. i dont find examples of transition animation for fragments.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.