Welcome to Software Development on Codidact!
Will you help us build our independent community of developers helping developers? We're small and trying to grow. We welcome questions about all aspects of software development, from design to code to QA and more. Got questions? Got answers? Got code you'd like someone to review? Please join us.
What's the minimum API level for activity transition?
I was trying to show transition on activity changes. I had followed two method from SO. I lost those link so I can't add them here.
My first method was I had used overridePendingTransition
on onCreate method.
overridePendingTransition(R.anim.fadein, R.anim.fadeout);
I had executed it in Android Device (API level : 21). Lollipop... Version 5.1
To me it was looking like the function doesn't work in under API level 23. I had searched in internet little bit but, didn't find. So, I was trying to do it another way.
I had added following lines to themes.xml
<style name="WindowAnimationTransition">
<item name="android:windowEnterAnimation">@android:anim/fade_in</item>
<item name="android:windowExitAnimation">@android:anim/fade_out</item>
</style>
And, used following code in Theme.Myapplication
<item name="android:windowAnimationStyle">@style/WindowAnimationTransition</item>
<item name="android:windowActivityTransitions">true</item>
I had copy-pasted the lines from SO. As you can see there's something written tools:targetApi="l"
. I think l
is representing Lollipop not sure if it is correct. If It is correct than it should work my device.
I was trying to execute the application in Virtual Android Device. When I was trying to start that Virtual device then my laptop started lagging that's why I didn't use Virtual Device.
I had followed the answer and another answer in that question.
1 answer
It worked for me hardly.
Intent intent = new Intent(Activity.this, SecondActivity.class);
ActivityOptions options = ActivityOptions.makeSceneTransitionAnimation(Activity.this);
startActivity(intent, options.toBundle());
According to the answer, R.anim was available from API level 1 and above.
According to the answer, overridePendingTransistion
was available from Android version 2.0 and above. 2.0 is called Eclair as an android app developer I will call it E (API level is 5).
According to the answer, ActivityCompat.startActivity()
works for API level 22 and above.
And, answer of the code is available here
In the code written above, options is making transition and when I had added it to startActivity
then, when changing the activity; it was sending transition animation with intent.
For custom transition :
Intent i = new Intent(Activity.this, SecondActivity.class);
ActivityOptions options = ActivityOptions.makeCustomAnimation(Activity.this, R.anim.fade, R.anim.fade_out);
startActivity(i,options.toBundle());
0 comment threads