use of android.view.animation.TranslateAnimation in project afwall by ukanth.
the class RadialMenuWidget method onCloseAnimation.
private void onCloseAnimation() {
// rotate = new RotateAnimation(360, 0, xPosition, yPosition);
scale = new ScaleAnimation(1, 0, 1, 0, xPosition, yPosition);
scale.setInterpolator(new AccelerateInterpolator());
move = new TranslateAnimation(0, xSource - xPosition, 0, ySource - yPosition);
spriteAnimation = new AnimationSet(true);
// spriteAnimation.addAnimation(rotate);
spriteAnimation.addAnimation(scale);
spriteAnimation.addAnimation(move);
spriteAnimation.setDuration(animationSpeed);
startAnimation(spriteAnimation);
}
use of android.view.animation.TranslateAnimation in project DMGameApp by xiaohaibin.
the class ClearEditText method shakeAnimation.
/**
* 晃动动画
*
* @param counts 1秒钟晃动多少下
* @return
*/
public static Animation shakeAnimation(int counts) {
Animation translateAnimation = new TranslateAnimation(0, 10, 0, 0);
translateAnimation.setInterpolator(new CycleInterpolator(counts));
translateAnimation.setDuration(1000);
return translateAnimation;
}
use of android.view.animation.TranslateAnimation in project open-event-android by fossasia.
the class AboutFragment method collapseExpandTextView.
@TargetApi(16)
void collapseExpandTextView() {
// translation animation of event bar
TranslateAnimation eventBarDownDirection = new TranslateAnimation(0, 0, -eventDescription.getHeight(), 0);
eventBarDownDirection.setInterpolator(new LinearInterpolator());
eventBarDownDirection.setDuration(300);
TranslateAnimation eventBarUpDirection = new TranslateAnimation(0, 0, eventDescription.getHeight(), 0);
eventBarUpDirection.setInterpolator(new LinearInterpolator());
eventBarUpDirection.setDuration(300);
// fading in or out of content
AlphaAnimation contentAppear = new AlphaAnimation(0, 1);
AlphaAnimation contentDisappear = new AlphaAnimation(1, 0);
if (eventDescription.getVisibility() == View.GONE) {
// it's collapsed - expand it.
slidinDownPart.startAnimation(eventBarDownDirection);
eventDescription.startAnimation(contentAppear);
eventDescription.setVisibility(View.VISIBLE);
descriptionImg.setImageResource(R.drawable.ic_expand_less_black_24dp);
} else {
// it's expanded - collapse it.
slidinDownPart.startAnimation(eventBarUpDirection);
eventDescription.startAnimation(contentDisappear);
eventDescription.setVisibility(View.GONE);
descriptionImg.setImageResource(R.drawable.ic_expand_more_black_24dp);
}
}
use of android.view.animation.TranslateAnimation in project KL2 by jweihao.
the class ViewAnimationActivity method onViewClicked.
@OnClick({ R.id.button_alpha, R.id.button_rotate, R.id.button_translate, R.id.button_scale, R.id.button_set })
public void onViewClicked(View view) {
switch(view.getId()) {
// 透明
case R.id.button_alpha:
AlphaAnimation aa = new AlphaAnimation(0, 1);
aa.setDuration(2000);
mImageview.startAnimation(aa);
break;
// 旋转
case R.id.button_rotate:
// 参数为,旋转的起始角度,旋转中心点的坐标。(这里设置的是旋转参考系为自身中心点)
RotateAnimation ra = new RotateAnimation(0, 360, RotateAnimation.RELATIVE_TO_SELF, 0.5F, RotateAnimation.RELATIVE_TO_SELF, 0.5F);
ra.setDuration(2000);
mImageview.startAnimation(ra);
break;
// 位移
case R.id.button_translate:
TranslateAnimation ta = new TranslateAnimation(0, 100, 0, 800);
ta.setDuration(3000);
// 使用位移来实现监听事件功能
ta.setAnimationListener(new Animation.AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
Toast.makeText(ViewAnimationActivity.this, "开始 TranslateAnimation", Toast.LENGTH_SHORT).show();
}
@Override
public void onAnimationEnd(Animation animation) {
Toast.makeText(ViewAnimationActivity.this, "结束 TranslateAnimation", Toast.LENGTH_SHORT).show();
}
// 通知动画的重复
@Override
public void onAnimationRepeat(Animation animation) {
}
});
mImageview.startAnimation(ta);
break;
// 缩放
case R.id.button_scale:
// (设置参数缩放的中心点为自身中心点,从0放大到2倍)
ScaleAnimation sa = new ScaleAnimation(0, 2, 0, 2, Animation.RELATIVE_TO_SELF, 0.5F, Animation.RELATIVE_TO_SELF, 0.5F);
sa.setDuration(3000);
mImageview.startAnimation(sa);
break;
// 动画集合,通过AnimationSet,可以将动画以组合的形式展现出来。
case R.id.button_set:
// 动画集合
AnimationSet as = new AnimationSet(true);
as.setDuration(3000);
// 透明
AlphaAnimation alpha = new AlphaAnimation(0, 1);
alpha.setDuration(3000);
as.addAnimation(alpha);
// 位移
TranslateAnimation translate = new TranslateAnimation(0, 100, 0, 800);
translate.setDuration(3000);
as.addAnimation(translate);
mImageview.startAnimation(as);
break;
default:
break;
}
}
use of android.view.animation.TranslateAnimation in project mixpanel-android by mixpanel.
the class InAppFragment method onAttach.
// It's safe to use onAttach(Activity) in API 23 as its implementation has not been changed.
// Bypass the Lint check for now.
@SuppressWarnings("deprecation")
@Override
public void onAttach(Activity activity) {
super.onAttach(activity);
mParent = activity;
if (null == mDisplayState) {
cleanUp();
return;
}
// We have to manually clear these Runnables in onStop in case they exist, since they
// do illegal operations when onSaveInstanceState has been called already.
mHandler = new Handler();
mRemover = new Runnable() {
public void run() {
InAppFragment.this.remove();
}
};
mDisplayMini = new Runnable() {
@Override
public void run() {
mInAppView.setVisibility(View.VISIBLE);
mInAppView.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View view, MotionEvent event) {
return InAppFragment.this.mDetector.onTouchEvent(event);
}
});
final ImageView notifImage = (ImageView) mInAppView.findViewById(R.id.com_mixpanel_android_notification_image);
final float heightPx = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 65, mParent.getResources().getDisplayMetrics());
final TranslateAnimation translate = new TranslateAnimation(0, 0, heightPx, 0);
translate.setInterpolator(new DecelerateInterpolator());
translate.setDuration(200);
mInAppView.startAnimation(translate);
final ScaleAnimation scale = new ScaleAnimation(0.0f, 1.0f, 0.0f, 1.0f, heightPx / 2, heightPx / 2);
scale.setInterpolator(new SineBounceInterpolator());
scale.setDuration(400);
scale.setStartOffset(200);
notifImage.startAnimation(scale);
}
};
mDetector = new GestureDetector(activity, new GestureDetector.OnGestureListener() {
@Override
public boolean onDown(MotionEvent e) {
return true;
}
@Override
public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
if (velocityY > 0) {
remove();
}
return true;
}
@Override
public void onLongPress(MotionEvent e) {
}
@Override
public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) {
return false;
}
@Override
public void onShowPress(MotionEvent e) {
}
@Override
public boolean onSingleTapUp(MotionEvent event) {
final MiniInAppNotification inApp = (MiniInAppNotification) mDisplayState.getInAppNotification();
JSONObject trackingProperties = null;
final String uriString = inApp.getCtaUrl();
if (uriString != null && uriString.length() > 0) {
Uri uri;
try {
uri = Uri.parse(uriString);
} catch (IllegalArgumentException e) {
MPLog.i(LOGTAG, "Can't parse notification URI, will not take any action", e);
return true;
}
try {
Intent viewIntent = new Intent(Intent.ACTION_VIEW, uri);
mParent.startActivity(viewIntent);
} catch (ActivityNotFoundException e) {
MPLog.i(LOGTAG, "User doesn't have an activity for notification URI " + uri);
}
try {
trackingProperties = new JSONObject();
trackingProperties.put("url", uriString);
} catch (final JSONException e) {
MPLog.e(LOGTAG, "Can't put url into json properties");
}
}
mMixpanel.getPeople().trackNotification("$campaign_open", inApp, trackingProperties);
remove();
return true;
}
});
}
Aggregations