I need to use reverse() method of Android AnimatorSet class. The problem is that this method was added only in api 26. But I found reverse method in source code in package androidx.animation. And I couldn't find any androidx library that allows to use that AnimatorSet (androidx.animation.AnimatorSet). How can I use that class?
For Api >=26 you just create an AnimatorSet object and after you define the animation you call reverse on it:
AnimatorSet animatorSet = new AnimatorSet();
animatorSet.playSequentially(ObjectAnimator.ofFloat(...), ...);
animatorSet.setDuration(...);
animatorSet.reverse();
animatorSet.start();
For older APIs you just reverse the order within the .ofFloat methods in your ObjectAnimators:
If initially you have ObjectAnimator.ofFloat(0, 1) you change it to animator.setFloatValues(1, 0)
If you don't care it's still in alpha, you can import it from here:
// To use the Animator APIs
implementation "androidx.core:core-animation:1.0.0-alpha01"
// To test the Animator APIs
androidTestImplementation "androidx.core:core-animation-testing:1.0.0-alpha01"
```
Related
LicenceManager.getInstance().setRestAPIKey("your_rest_api_key");
LicenceManager.getInstance().setMapSDKKey("your_java_script_key");
I have compiled the latest maps sdk 2.3.0. Here .setRestAPIKey() and .setMapSDKKey() methods are not working. Inside the LicenseManager.class I found .setMapmyIndiaBeaconToken() method.
Instead of using LicenceManager use `MapmyIndiaAccountManager' class.
The full implementation is
MapmyIndiaAccountManager.getInstance().setMapSDKKey("your_java_script_key");
MapmyIndiaAccountManager.getInstance().setRestAPIKey("your_rest_api_key");
I'm trying to make an animation in my app available in older android version and I'm using ViewPropertyAnimator by calling view.animate().
But how can I get a ViewPropertyAnimatorCompat of the view?
Use ViewCompat.
ViewPropertyAnimatorCompat animator = ViewCompat.animate(view);
I'm trying to create an Object Animator in Android using the following code:
ObjectAnimator animation = new ObjectAnimator.ofInt(...);
although the compiler keeps throwing an error under "ofInt" saying:
Cannot resolve Symbol 'ofInt'
What am I doing wrong it's driving me crazy.
new ObjectAnimator().ofInt(..)
i think youre forgetting () *constructor/method call
The call ObjectAnimator animation = new ObjectAnimator.ofInt(...);
is wrong, you need to call the constructor properly and then call the methods you need...
ObjectAnimator animation = new ObjectAnimator();
animation.ofInt(...);
Can i use objectAnimator in xml in api level 2.2 for fragment transition to to get more types of animation?? or provide me xml for animations like glide, cube, stack etc provided with API 11 and above wich supports API 8 too.
private void transitionFade() {
mFragmentTransaction.setCustomAnimations(android.R.anim.fade_in,android.R.anim.fade_out,android.R.anim.fade_in,android.R.anim.fade_out);
}
The above method with "anim" works fine in API8
but below code doesn't work with "animator"
private void transitionGlide() {
mFragmentTransaction.setCustomAnimations(R.animator.glide_fragment_horizontal_in, R.animator.glide_fragment_horizontal_out, R.animator.glide_fragment_horizontal_in, R.animator.glide_fragment_horizontal_out);
}
No, you cannot directly, as ObjectAnimator appeared in API11, however you can try to use backport of Honeycomb Animation system NineOldAndroids
problem in this code ?
its work on android 4 successfully ! but don't work on 2.2 !
i use nineoldandroids library for android API 8
if(Build.VERSION.SDK_INT > 13) {
v.setTranslationX(0.0F);
v.setTranslationY(height);
v.setRotationX(45.0F);
v.setScaleX(0.7F);
v.setScaleY(0.55F);
ViewPropertyAnimator localViewPropertyAnimator =
v.animate().rotationX(0.0F).rotationY(0.0F).translationX(0).translationY(0).setDuration(animDuration).scaleX(
1.0F).scaleY(1.0F).setInterpolator(interpolator);
localViewPropertyAnimator.setStartDelay(0).start();
} else {
com.nineoldandroids.view.ViewPropertyAnimator.animate(v).translationX(0.0F).translationY(height)
.rotationX(45.0F).scaleX(0.7F).scaleY(0.55F);
com.nineoldandroids.view.ViewPropertyAnimator.animate(v).setStartDelay(0).start();
com.nineoldandroids.view.ViewPropertyAnimator.animate(v).rotationX(0.0F).rotationY(0.0F).translationX(0).translationY(0).setDuration(animDuration).scaleX(
1.0F).scaleY(1.0F).setInterpolator(interpolator);
com.nineoldandroids.view.ViewPropertyAnimator.animate(v).setStartDelay(animDuration).start();
}
sorry for bad english !
tnx to all
-------------------------------EDIT-----------------------------
code executed right on android 2.2 but not like android 4 !
ViewPropertyAnimator is for api level >11.However; you can use nineoldandroids library project which is a proxy for this animations (and quite good).
Or you can simply use Animation class
UPDATE:
i missed the part you said u already use nineoldandroids. did you check your imports maybe you imported the native
ViewPropertyAnimation
it may cause problem too. That libray uses the native api if api level is >11 you dont need to import native one.
You need to import ViewHelper class of nineoldandroid like
import com.nineoldandroids.view.ViewHelper;
and then use following code
ViewHelper.setTranslationX( Your View, 0.0F);
ViewHelper.setTranslationY( Your View, height);
ViewHelper.setRotationX(Your View,45.0F);
ViewHelper.setScaleX(Your View,0.7F);
ViewHelper.setScaleY(Your View,0.55F);
instead of
v.setTranslationX(0.0F);
v.setTranslationY(height);
v.setRotationX(45.0F);
v.setScaleX(0.7F);
v.setScaleY(0.55F);
Since Nineoldandroids allow api 1> use animation methods.
However, I run in API8 and Force Close is occured!
HERE is the solution, it's because of Nineoldandroids
[http://answer.techwikihow.com/962376/nineoldandroids-animation-working-api10.html][1]
Use Library of NineOldndroids Folder as Dependency instead of .jar,
Modification some code in
ObjectAnimator.Class
by following the answer in the link above!