Widget - Layout Animation Slide

//Create Linear1

//Add Linear2 to Linear1

//OnCreate
linear2.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View p1, MotionEvent p2) {
switch(p2.getAction()) {
case MotionEvent.ACTION_DOWN:
f = p2.getY();
break;
case MotionEvent.ACTION_UP:
t = p2.getY();
if (((f - t) < -250)) {
_slideDown();
}
if (((t - f) < -250)) {
_slideUp();
}
break;
}
return true;
}});

//_slideDown
ObjectAnimator animX = ObjectAnimator.ofFloat(linear2, "x", 300f);
ObjectAnimator animY = ObjectAnimator.ofFloat(linear2, "y", 700f);
AnimatorSet animSetXY = new AnimatorSet();
animSetXY.playTogether(animX, animY);
animSetXY.start();


//_slideUp
ObjectAnimator animX = ObjectAnimator.ofFloat(linear2, "x", 0f);
ObjectAnimator animY = ObjectAnimator.ofFloat(linear2, "y", 0f);
AnimatorSet animSetXY = new AnimatorSet();
animSetXY.playTogether(animX, animY);
animSetXY.start();

Komentar

Cara pembuatan Apps paling Populer

Create Stopwatch App in Android using Sketchware

How to enable download in webview in Sketchware apps?

TextInputLayout in Sketchware

Create Stopwatch App in Android using Sketchware

How to integrate Admob Ads in Sketchware project using AIDE?

How to find and​ highlight a word in a text field in Sketchware?

Code for implementing Notifications in Sketchware

A Flash Light App in Sketchware

Create a Stopwatch App using Chronometer in Sketchware

Create app to save all passwords, protected using voice key