https://youtu.be/1c2TYKv50Ic
What is the bonus (HEMEN AL)button animation code included in the video. Could you help
code:
int basY =100;
int sonY = 10;
CipView cip = new CipView(context);
AnimatorSet1 = new AnimatorSet();
ObjectAnimator starScaleYAnimator = ObjectAnimator.ofFloat(cip, View.SCALE_Y, 0.5f);
starScaleYAnimator.setDuration(350);
starScaleYAnimator.setStartDelay(300);
ObjectAnimator starScaleXAnimator = ObjectAnimator.ofFloat(cip, View.SCALE_X, 0.5f);
starScaleXAnimator.setDuration(350);
starScaleXAnimator.setStartDelay(300);
AnimatorSet1.playTogether(starScaleYAnimator, starScaleXAnimator);
AnimatorSet1.start();
int basY =100;
int sonY = 10;
CipView cip = new CipView(context);
AnimatorSet1 = new AnimatorSet();
ObjectAnimator starScaleYAnimator = ObjectAnimator.ofFloat(cip, "scaleY", basY, sonY);
starScaleYAnimator.setDuration(350);
starScaleYAnimator.setStartDelay(300);
ObjectAnimator starScaleXAnimator = ObjectAnimator.ofFloat(cip, "scaleX", basY, sonY);
starScaleXAnimator.setDuration(350);
starScaleXAnimator.setStartDelay(300);
AnimatorSet1.playTogether(starScaleYAnimator, starScaleXAnimator);
AnimatorSet1.start();
Related
I have an activity, and on onCreate I run this piece of code:
AnimationSet animation = new AnimationSet(true);
animation.addAnimation(new AlphaAnimation(0f, 1f));
animation.addAnimation(new ScaleAnimation(0f, 1f, 0f, 1f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f));
animation.setDuration(4000); // should be 300
animation.setFillAfter(true);
View i1 = findViewById(R.id.load_mainimg);
View i2 = findViewById(R.id.load_text1);
View i3 = findViewById(R.id.load_text2);
View i4 = findViewById(R.id.load_imgbtn_about);
View i5 = findViewById(R.id.load_imgbtn_settings);
View i6 = findViewById(R.id.load_btn1);
View i7 = findViewById(R.id.load_btn2);
i1.startAnimation(animation);
...
i7.startAnimation(animation);
However, the TextViews (i2, i3) and the ImageButtons (i4, i5) doesn't scale from the center. (i1 is an ImageView, i6 and i7 are LinearLayouts.) What am I doing wrong?
I have two views in different layouts I want to move one to another. What's wrong with my code? Y animation plays wrong. First view is located in fragment's layout, second in status bar
...
int p1[] = new int[2];
int p2[] = new int[2];
viewOne.getLocationInWindow(p1);
viewTwo.getLocationInWindow(p2);
AnimatorSet animatorSet = new AnimatorSet();
animatorSet
.play(ObjectAnimator.ofFloat(expandedImageView, "X", p1[0], p2[0] - p1[0]))
.with(ObjectAnimator.ofFloat(expandedImageView, "Y", p1[1], p2[1] - p1[1]))
.with(ObjectAnimator.ofFloat(expandedImageView, View.SCALE_X, startScale))
.with(ObjectAnimator.ofFloat(expandedImageView, View.SCALE_Y, startScale));
I have a another solution for you:(move viewOne to viewTwo)
TranslateAnimation animation = new TranslateAnimation(0, viewTwo.getX()-viewOne.getX(),0 , viewTwo.getY()-viewOne.getY());
animation.setRepeatMode(0);
animation.setDuration(3000);
animation.setFillAfter(true);
viewOne.startAnimation(animation);
Try this
private fun moveView(viewToBeMoved: View, targetView: View) {
val targetX: Float =
targetView.x + targetView.width / 2 - viewToBeMoved.width / 2
val targetY: Float =
targetView.y + targetView.height / 2 - viewToBeMoved.height / 2
viewToBeMoved.animate()
.x(targetX)
.y(targetY)
.setDuration(2000)
.withEndAction {
targetView.visibility = View.GONE
}
.start()
}
I have simple animation that moves the object in Y axis. I want change the behavior for the REVERSE.
//My Code:
ImageView iv = ... //my view
ObjectAnimator oa = ObjectAnimator.ofFloat(iv, "y", 300);
oa.setDuration(100);
oa.setRepeatCount(1);
oa.setRepeatMode(ValueAnimator.REVERSE);
oa.start();
You cannot change the behavior of the reverse mode. Instead, you will need to create an AnimatorSet and play them sequentially.
ImageView iv = ... //my view
ObjectAnimator oa = ObjectAnimator.ofFloat(iv, "y", 300);
oa.setDuration(100);
ObjectAnimator oa2 = ObjectAnimator.ofFloat(/* code here */)
// Add any other code for oa2
AnimatorSet set = new AnimatorSet();
set.playSequentially(oa, oa2);
set.start()
public void animateScreenOn() {
CellLayout layout = (CellLayout) getChildAt(getCurrentPage());
if (layout != null) {
int count = layout.getPageChildCount();
for (int i = count-1; i>=0; i--) {
View v = layout.getPageChild(i);
v.setScaleX(0.95f);
v.setScaleY(0.95f);
AnimatorSet set = new AnimatorSet();
ObjectAnimator animation1 = LauncherAnimUtils.ofPropertyValuesHolder(v,
PropertyValuesHolder.ofFloat("scaleX", 1.0f));
animation1.setDuration(1000L);
animation1.setInterpolator(new BounceInterpolator());
ObjectAnimator animation2 = LauncherAnimUtils.ofPropertyValuesHolder(v,
PropertyValuesHolder.ofFloat("scaleY", 1.0f));
animation2.setDuration(500L);
animation2.setInterpolator(new BounceInterpolator());
List<Animator> items = new ArrayList<Animator>();
items.add(animation1);
items.add(animation2);
set.playTogether(items);
set.setStartDelay((count-1-i)*100L);
set.start();
}
}
}
this code have an issue. the time of this code cost is different on different devices, some is ok, but some will be too short, so i need to change animate time depend on device refresh rate. anyone can tell me how to get it from android code, 3X!
I am creating an animation where my image will translate to a different spot on the screen and then fade in gradually. I completed the translation part(see below) but now when I start the fade in animation it disappears for the duration and then reapears after. I want to show the image being faded in gradually....Any ideas why this is happening?
public static int moveTwo(AnimationListener activity, View apa, int animationmove)
Log.v("MOVETWO", "Started move2");
AnimationSet picMov2 = new AnimationSet(true);
picMov2.setAnimationListener(activity);
RotateAnimation rotate2 = new RotateAnimation(0, 0,
Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF,
0.5f);
// rotate1.setStartOffset(50);
rotate2.setDuration(2000);
picMov2.addAnimation(rotate2);
TranslateAnimation trans2 = new TranslateAnimation(-200, -400, 0, 0);
trans2.setDuration(2000);
picMov2.setFillAfter(true);
picMov2.addAnimation(trans2);
apa.startAnimation(picMov2);
animationmove = 3;
return animationmove;
public static int moveThree(AnimationListener activity, View apa, int animationmove)
AlphaAnimation fadein = new AlphaAnimation((float) 0.3, 1);//HERE THE IMAGE IS DISAPPEARING
fadein.setAnimationListener(activity);
fadein.setDuration(2000);
fadein.setFillAfter(true);
apa.startAnimation(fadein);
animationmove=4;
return animationmove;
Just needed to create a translate action in the same place so it doesn't go back to its original position
public static int moveThree(AnimationListener activity, View apa, int animationmove)
{
Log.v("MOVETHREE", "Started move3");
AnimationSet picMov3 = new AnimationSet(true);
picMov3.setAnimationListener(activity);
AlphaAnimation fadein = new AlphaAnimation((float) 0.4, 1);
// rotate1.setStartOffset(50);
fadein.setDuration(duration);
picMov3.addAnimation(fadein);
TranslateAnimation trans1 = new TranslateAnimation(-400, -400, 0, 0);
trans1.setDuration(duration);
picMov3.setFillAfter(true);
picMov3.addAnimation(trans1);
apa.startAnimation(picMov3);