private void gotoMenu() { if (userPagelayout != null) { isAnimationOpen = !isAnimationOpen; if (isAnimationOpen) { if (mainMenu != null) { mainMenu.setIsCanClick(true); } mHandler.removeMessages(MessageID.MESSAGE_CONNECT_LAYOUTOVER); Animation animation = AnimationUtils.loadAnimation(this, R.anim.right_out); animation.setFillEnabled(true); animation.setFillAfter(true); animation.setAnimationListener(this); // 动画播放,实际布局坐标不变 userPagelayout.startAnimation(animation); OfflineLog.writeMainMenu(); // 写入离线日志 } else { if (mainMenu != null) { mainMenu.setIsCanClick(false); } Animation animation = AnimationUtils.loadAnimation(this, R.anim.left_in); animation.setAnimationListener(this); animation.setFillEnabled(true); animation.setFillAfter(true); userPagelayout.startAnimation(animation); } } }
private void initView(Context context) { // 初始情况,设置下拉刷新view高度为0 LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, 0); mContainer = (LinearLayout) LayoutInflater.from(context).inflate(R.layout.xlistview_header, null); addView(mContainer, lp); setGravity(Gravity.BOTTOM); mArrowImageView = (ImageView) findViewById(R.id.xlistview_header_arrow); mHintTextView = (TextView) findViewById(R.id.xlistview_header_hint_textview); mProgressBar = (ImageView) findViewById(R.id.xlistview_header_progressbar); mProgressBar.setVisibility(View.GONE); mRotateUpAnim = new RotateAnimation( 0.0f, -180.0f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); mRotateUpAnim.setDuration(ROTATE_ANIM_DURATION); mRotateUpAnim.setFillAfter(true); mRotateDownAnim = new RotateAnimation( -180.0f, 0.0f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); mRotateDownAnim.setDuration(ROTATE_ANIM_DURATION); mRotateDownAnim.setFillAfter(true); mLoadingAni = new RotateAnimation( 0f, 359f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); mLoadingAni.setDuration(1000); mLoadingAni.setRepeatCount(Animation.INFINITE); mLoadingAni.setRepeatMode(Animation.RESTART); mLoadingAni.setInterpolator(new LinearInterpolator()); }
@SuppressLint("InflateParams") private void initView(Context context) { // 初始情况,设置下拉刷新view高度为0 LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(android.view.ViewGroup.LayoutParams.MATCH_PARENT, 0); mContainer = (RelativeLayout) LayoutInflater.from(context).inflate(R.layout.xlistview_header, null); addView(mContainer, lp); setGravity(Gravity.BOTTOM); mArrowImageView = (ImageView) findViewById(R.id.xlistview_header_arrow); mHintTextView = (TextView) findViewById(R.id.xlistview_header_hint_textview); mProgressBar = (ProgressBar) findViewById(R.id.xlistview_header_progressbar); mHeaderTimeView = (TextView) findViewById(R.id.xlistview_header_time); mHeaderTimeLabel = (TextView) findViewById(R.id.xlistview_header_time_label); mRotateUpAnim = new RotateAnimation( 0.0f, -180.0f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); mRotateUpAnim.setDuration(ROTATE_ANIM_DURATION); mRotateUpAnim.setFillAfter(true); mRotateDownAnim = new RotateAnimation( -180.0f, 0.0f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); mRotateDownAnim.setDuration(ROTATE_ANIM_DURATION); mRotateDownAnim.setFillAfter(true); }
private void initView(Context context) { setOrientation(LinearLayout.VERTICAL); LayoutParams lp = new LayoutParams(LayoutParams.MATCH_PARENT, 0); mContainer = (LinearLayout) LayoutInflater.from(context).inflate(R.layout.zlibrary_xlistview_header, null); addView(mContainer, lp); setGravity(Gravity.BOTTOM); mArrowImageView = (ImageView) findViewById(R.id.xlistview_header_arrow); mHintTextView = (TextView) findViewById(R.id.xlistview_header_hint_textview); mProgressBar = (ProgressBar) findViewById(R.id.xlistview_header_progressbar); mProgressBar.setVisibility(View.INVISIBLE); mRotateUpAnim = new RotateAnimation( 0.0f, -180.0f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); mRotateUpAnim.setDuration(ROTATE_ANIM_DURATION); mRotateUpAnim.setFillAfter(true); mRotateDownAnim = new RotateAnimation( -180.0f, 0.0f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); mRotateDownAnim.setDuration(ROTATE_ANIM_DURATION); mRotateDownAnim.setFillAfter(true); }
private void initView(Context context) { // 初始情况,设置下拉刷新view高度为0 LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, 0); mContainer = (LinearLayout) LayoutInflater.from(context).inflate(R.layout.xlistview_header, null); addView(mContainer, lp); setGravity(Gravity.BOTTOM); mArrowImageView = (ImageView) findViewById(R.id.xlistview_header_arrow); mHintTextView = (TextView) findViewById(R.id.xlistview_header_hint_textview); mProgressBar = (ImageView) findViewById(R.id.xlistview_header_progressbar); mRotateUpAnim = new RotateAnimation( 0.0f, -180.0f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); mRotateUpAnim.setDuration(ROTATE_ANIM_DURATION); mRotateUpAnim.setFillAfter(true); mRotateDownAnim = new RotateAnimation( -180.0f, 0.0f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); mRotateDownAnim.setDuration(ROTATE_ANIM_DURATION); mRotateDownAnim.setFillAfter(true); mProgressBar.setImageResource(R.anim.loadmore_animation); animationDrawable = (AnimationDrawable) mProgressBar.getDrawable(); animationDrawable.setOneShot(false); }
private void moveLeft(cgCacheView holder, cgCache cache, boolean force) { if (cache == null) { return; } holder.checkbox.setChecked(cache.isStatusChecked()); // slide cache info final Animation hideCheckbox = new TranslateAnimation((int) (SWIPE_DISTANCE * pixelDensity), 0, 0, 0); hideCheckbox.setRepeatCount(0); hideCheckbox.setDuration(force ? 0 : 400); hideCheckbox.setFillEnabled(true); hideCheckbox.setFillAfter(true); hideCheckbox.setInterpolator(new AccelerateDecelerateInterpolator()); // brighten cache info final Animation brightenInfo = new AlphaAnimation(SWIPE_OPACITY, 1.0f); brightenInfo.setRepeatCount(0); brightenInfo.setDuration(force ? 0 : 400); brightenInfo.setFillEnabled(true); brightenInfo.setFillAfter(true); brightenInfo.setInterpolator(new AccelerateDecelerateInterpolator()); // animation set (container) final AnimationSet selectAnimation = new AnimationSet(true); selectAnimation.setFillEnabled(true); selectAnimation.setFillAfter(true); selectAnimation.addAnimation(hideCheckbox); selectAnimation.addAnimation(brightenInfo); holder.oneInfo.startAnimation(selectAnimation); cache.setStatusCheckedView(false); }
private void init() { LayoutInflater.from(getContext()).inflate(R.layout.slider, this); slideInTop.setFillAfter(true); slideOutTop.setFillAfter(true); slideInBottom.setFillAfter(true); slideOutBottom.setFillAfter(true); slideInTop.setAnimationListener( new AnimationListener() { public void onAnimationStart(Animation animation) { // TODO Auto-generated method stub } public void onAnimationRepeat(Animation animation) { // TODO Auto-generated method stub } public void onAnimationEnd(Animation animation) { Log.d("gogo", "show = true"); show = true; } }); slideOutTop.setAnimationListener( new AnimationListener() { public void onAnimationStart(Animation animation) { // TODO Auto-generated method stub } public void onAnimationRepeat(Animation animation) { // TODO Auto-generated method stub } public void onAnimationEnd(Animation animation) { Log.d("gogo", "show = false"); show = false; } }); mMaskView = (MaskView) findViewById(R.id.mask); mMaskView.setOnClickListener(this); mTopBar = findViewById(R.id.top_bar); mTopBar.setOnClickListener(this); mBootomBar = findViewById(R.id.bottom_bar); mBootomBar.setOnClickListener(this); mViewPager = (HackyViewPager) findViewById(R.id.viewpager); mTitleView = (TextView) findViewById(R.id.title); mDescrView = (TextView) findViewById(R.id.descr); mOrderView = (TextView) findViewById(R.id.order); mBackView = findViewById(R.id.back); mDownloadView = findViewById(R.id.download); mNextView = findViewById(R.id.next); mQuitView = findViewById(R.id.quit); mQuitView.setOnClickListener(this); // buildViewPager(); }
/** * 初始化 * * @param context context */ private void init(Context context) { mHeaderContainer = (RelativeLayout) findViewById(R.id.pull_to_refresh_header_content); mArrowImageView = (ImageView) findViewById(R.id.pull_to_refresh_header_arrow); mHintTextView = (TextView) findViewById(R.id.pull_to_refresh_header_hint_textview); mProgressBar = (ProgressBar) findViewById(R.id.pull_to_refresh_header_progressbar); mHeaderTimeView = (TextView) findViewById(R.id.pull_to_refresh_header_time); mHeaderTimeViewTitle = (TextView) findViewById(R.id.pull_to_refresh_last_update_time_text); float pivotValue = 0.5f; // SUPPRESS CHECKSTYLE float toDegree = -180f; // SUPPRESS CHECKSTYLE // 初始化旋转动画 mRotateUpAnim = new RotateAnimation( 0.0f, toDegree, Animation.RELATIVE_TO_SELF, pivotValue, Animation.RELATIVE_TO_SELF, pivotValue); mRotateUpAnim.setDuration(ROTATE_ANIM_DURATION); mRotateUpAnim.setFillAfter(true); mRotateDownAnim = new RotateAnimation( toDegree, 0.0f, Animation.RELATIVE_TO_SELF, pivotValue, Animation.RELATIVE_TO_SELF, pivotValue); mRotateDownAnim.setDuration(ROTATE_ANIM_DURATION); mRotateDownAnim.setFillAfter(true); }
/** * Create a pair of {@link FlipAnimation} that can be used to flip 3D transition from {@code * fromView} to {@code toView}. A typical use case is with {@link ViewAnimator} as an out and in * transition. * * <p>NOTE: Avoid using this method. Instead, use {@link #flipTransition}. * * @param fromView the view transition away from * @param toView the view transition to * @param dir the flip direction * @param duration the transition duration in milliseconds * @param interpolator the interpolator to use (pass {@code null} to use the {@link * AccelerateInterpolator} interpolator) * @return */ public static Animation[] flipAnimation( final View fromView, final View toView, FlipDirection dir, long duration, Interpolator interpolator) { Animation[] result = new Animation[2]; float centerX; float centerY; centerX = fromView.getWidth() / 2.0f; centerY = fromView.getHeight() / 2.0f; Animation outFlip = new FlipAnimation( dir.getStartDegreeForFirstView(), dir.getEndDegreeForFirstView(), centerX, centerY, FlipAnimation.SCALE_DEFAULT, FlipAnimation.ScaleUpDownEnum.SCALE_DOWN); outFlip.setDuration(duration); outFlip.setFillAfter(true); outFlip.setInterpolator(interpolator == null ? new AccelerateInterpolator() : interpolator); AnimationSet outAnimation = new AnimationSet(true); outAnimation.addAnimation(outFlip); result[0] = outAnimation; // Uncomment the following if toView has its layout established (not the case if using // ViewFlipper and on first show) // centerX = toView.getWidth() / 2.0f; // centerY = toView.getHeight() / 2.0f; Animation inFlip = new FlipAnimation( dir.getStartDegreeForSecondView(), dir.getEndDegreeForSecondView(), centerX, centerY, FlipAnimation.SCALE_DEFAULT, FlipAnimation.ScaleUpDownEnum.SCALE_UP); inFlip.setDuration(duration); inFlip.setFillAfter(true); inFlip.setInterpolator(interpolator == null ? new AccelerateInterpolator() : interpolator); inFlip.setStartOffset(duration); AnimationSet inAnimation = new AnimationSet(true); inAnimation.addAnimation(inFlip); result[1] = inAnimation; return result; }
public IndicatorLayout(Context context, PullToRefreshBase.Mode mode) { super(context); mArrowImageView = new ImageView(context); Drawable arrowD = getResources().getDrawable(R.drawable.indicator_arrow); mArrowImageView.setImageDrawable(arrowD); final int padding = getResources().getDimensionPixelSize(R.dimen.indicator_internal_padding); mArrowImageView.setPadding(padding, padding, padding, padding); addView(mArrowImageView); int inAnimResId, outAnimResId; switch (mode) { case PULL_FROM_END: inAnimResId = R.anim.slide_in_from_bottom; outAnimResId = R.anim.slide_out_to_bottom; setBackgroundResource(R.drawable.indicator_bg_bottom); // Rotate Arrow so it's pointing the correct way mArrowImageView.setScaleType(ScaleType.MATRIX); Matrix matrix = new Matrix(); matrix.setRotate(180f, arrowD.getIntrinsicWidth() / 2f, arrowD.getIntrinsicHeight() / 2f); mArrowImageView.setImageMatrix(matrix); break; default: case PULL_FROM_START: inAnimResId = R.anim.slide_in_from_top; outAnimResId = R.anim.slide_out_to_top; setBackgroundResource(R.drawable.indicator_bg_top); break; } mInAnim = AnimationUtils.loadAnimation(context, inAnimResId); mInAnim.setAnimationListener(this); mOutAnim = AnimationUtils.loadAnimation(context, outAnimResId); mOutAnim.setAnimationListener(this); final Interpolator interpolator = new LinearInterpolator(); mRotateAnimation = new RotateAnimation( 0, -180, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); mRotateAnimation.setInterpolator(interpolator); mRotateAnimation.setDuration(DEFAULT_ROTATION_ANIMATION_DURATION); mRotateAnimation.setFillAfter(true); mResetRotateAnimation = new RotateAnimation( -180, 0, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); mResetRotateAnimation.setInterpolator(interpolator); mResetRotateAnimation.setDuration(DEFAULT_ROTATION_ANIMATION_DURATION); mResetRotateAnimation.setFillAfter(true); }
private void initSubViews() { mText = (TextView) findViewById(R.id.checkbox_txt); mImage = (ImageView) findViewById(R.id.checkbox_img); setOnClickListener(this); mDisabledAnim = new AlphaAnimation(0.4f, 0.4f); mDisabledAnim.setDuration(0); mDisabledAnim.setFillAfter(true); mEnabledAnim = new AlphaAnimation(1.0f, 1.0f); mEnabledAnim.setDuration(0); mEnabledAnim.setFillAfter(true); }
private void setupText1Marquee() { final int duration = (int) (mText1Difference * MS_PER_PX); mMoveText1TextOut = new TranslateAnimation(0, -mText1Difference, 0, 0); mMoveText1TextOut.setDuration(duration); mMoveText1TextOut.setInterpolator(new LinearInterpolator()); mMoveText1TextOut.setFillAfter(true); mMoveText1TextIn = new TranslateAnimation(-mText1Difference, 0, 0, 0); mMoveText1TextIn.setDuration(duration); mMoveText1TextIn.setStartOffset(PAUSE_BETWEEN_ANIMATIONS); mMoveText1TextIn.setInterpolator(new LinearInterpolator()); mMoveText1TextIn.setFillAfter(true); mMoveText1TextOut.setAnimationListener( new Animation.AnimationListener() { public void onAnimationStart(Animation animation) { // mMoveText1TextOutPlaying = true; expandTextView(mTextField1); } public void onAnimationEnd(Animation animation) { // mMoveText1TextOutPlaying = false; if (mCancelled) { return; } mTextField1.startAnimation(mMoveText1TextIn); } public void onAnimationRepeat(Animation animation) {} }); mMoveText1TextIn.setAnimationListener( new Animation.AnimationListener() { public void onAnimationStart(Animation animation) {} public void onAnimationEnd(Animation animation) { cutTextView(mTextField1); if (mCancelled) { return; } startTextField1Animation(); } public void onAnimationRepeat(Animation animation) {} }); }
private void initAnim() { long duration = 300; long durationS = 160; float alpha = 0.3f; AccelerateInterpolator accInterpolator = new AccelerateInterpolator(); tab_left = new TranslateAnimation(tabW, 0, 0, 0); tab_right = new TranslateAnimation(0, tabW, 0, 0); tab_alpha_1 = new AlphaAnimation(1.0f, alpha); tab_alpha_2 = new AlphaAnimation(alpha, 1.0f); pop_in = new ScaleAnimation( 0, 1, 0, 1, Animation.RELATIVE_TO_SELF, 1, Animation.RELATIVE_TO_SELF, 0); pop_out = new ScaleAnimation( 1, 0, 1, 0, Animation.RELATIVE_TO_SELF, 1, Animation.RELATIVE_TO_SELF, 0); pop_in.setDuration(durationS); pop_in.setInterpolator(accInterpolator); pop_in.setAnimationListener(new PopListener(popView, PopListener.TYPE_IN)); pop_out.setDuration(durationS); pop_out.setInterpolator(accInterpolator); pop_out.setAnimationListener(new PopListener(popView, PopListener.TYPE_OUT)); tab_left.setFillAfter(true); tab_left.setFillEnabled(true); tab_left.setDuration(duration); tab_left.setInterpolator(accInterpolator); tab_right.setFillAfter(true); tab_right.setFillEnabled(true); tab_right.setDuration(duration); tab_right.setInterpolator(accInterpolator); tab_alpha_1.setFillAfter(true); tab_alpha_1.setFillEnabled(true); tab_alpha_1.setDuration(duration); tab_alpha_1.setInterpolator(accInterpolator); tab_alpha_2.setFillAfter(true); tab_alpha_2.setFillEnabled(true); tab_alpha_2.setDuration(duration); tab_alpha_2.setInterpolator(accInterpolator); AlphaAnimation alphaInit = new AlphaAnimation(alpha, alpha); alphaInit.setFillAfter(true); alphaInit.setFillEnabled(true); tv_tab_box.startAnimation(alphaInit); }
public void onPageSelected(int arg0) { Animation animation = null; switch (arg0) { case 0: if (currIndex == 1) { animation = new TranslateAnimation(one, 0, 0, 0); } else if (currIndex == 2) { animation = new TranslateAnimation(two, 0, 0, 0); } break; case 1: if (currIndex == 0) { animation = new TranslateAnimation(offset, one, 0, 0); } else if (currIndex == 2) { animation = new TranslateAnimation(two, one, 0, 0); } break; case 2: if (currIndex == 0) { animation = new TranslateAnimation(offset, two, 0, 0); } else if (currIndex == 1) { animation = new TranslateAnimation(one, two, 0, 0); } break; } currIndex = arg0; animation.setFillAfter(true); // True:ͼƬͣÔÚ¶¯»½áÊøλÖà animation.setDuration(300); cursor.startAnimation(animation); }
private void showZoomedView() { // no animation if the zoomed view is already visible if (getVisibility() != View.VISIBLE) { final Animation anim = new ScaleAnimation( 0f, 1f, // Start and end values for the X axis scaling 0f, 1f, // Start and end values for the Y axis scaling Animation.ABSOLUTE, animationStart.x, // Pivot point of X scaling Animation.ABSOLUTE, animationStart.y); // Pivot point of Y scaling anim.setFillAfter(true); // Needed to keep the result of the animation anim.setDuration(OPENING_ANIMATION_DURATION_MS); anim.setInterpolator(new OvershootInterpolator(OVERSHOOT_INTERPOLATOR_TENSION)); anim.setAnimationListener( new AnimationListener() { public void onAnimationEnd(Animation animation) { setListeners(); } public void onAnimationRepeat(Animation animation) {} public void onAnimationStart(Animation animation) { removeListeners(); } }); setAnimation(anim); } setVisibility(View.VISIBLE); shouldSetVisibleOnUpdate = false; }
private void hideZoomedView(boolean withAnimation) { if (withAnimation) { final Animation anim = new ScaleAnimation( 1f, 0f, // Start and end values for the X axis scaling 1f, 0f, // Start and end values for the Y axis scaling Animation.ABSOLUTE, animationStart.x, // Pivot point of X scaling Animation.ABSOLUTE, animationStart.y); // Pivot point of Y scaling anim.setFillAfter(true); // Needed to keep the result of the animation anim.setDuration(CLOSING_ANIMATION_DURATION_MS); anim.setAnimationListener( new AnimationListener() { public void onAnimationEnd(Animation animation) {} public void onAnimationRepeat(Animation animation) {} public void onAnimationStart(Animation animation) { removeListeners(); } }); setAnimation(anim); } else { removeListeners(); setAnimation(null); } setVisibility(View.GONE); shouldSetVisibleOnUpdate = false; }
/** * 初始化 * * @param context context */ private void init(Context context) { mHeaderContainer = (RelativeLayout) findViewById(R.id.pull_to_refresh_header_content); mArrowImageView = (ImageView) findViewById(R.id.pull_to_refresh_header_arrow); mHintTextView = (TextView) findViewById(R.id.pull_to_refresh_header_hint_textview); mHeaderTimeView = (TextView) findViewById(R.id.pull_to_refresh_header_time); mHeaderTimeViewTitle = (TextView) findViewById(R.id.pull_to_refresh_last_update_time_text); mArrowImageView.setScaleType(ScaleType.CENTER); mArrowImageView.setImageResource(R.drawable.default_ptr_rotate); float pivotValue = 0.5f; // SUPPRESS CHECKSTYLE float toDegree = 720.0f; // SUPPRESS CHECKSTYLE mRotateAnimation = new RotateAnimation( 0.0f, toDegree, Animation.RELATIVE_TO_SELF, pivotValue, Animation.RELATIVE_TO_SELF, pivotValue); mRotateAnimation.setFillAfter(true); mRotateAnimation.setInterpolator(ANIMATION_INTERPOLATOR); mRotateAnimation.setDuration(ROTATION_ANIMATION_DURATION); mRotateAnimation.setRepeatCount(Animation.INFINITE); mRotateAnimation.setRepeatMode(Animation.RESTART); }
@Override public void onClick(View view) { mCollapsed = !mCollapsed; mButton.setImageDrawable(mCollapsed ? mExpandDrawable : mCollapseDrawable); mAnimating = true; Animation animation; if (mCollapsed) { animation = new ExpandCollapseAnimation(this, mMinHeight, mHeight); // kuo } else { animation = new ExpandCollapseAnimation(this, mHeight, mMinHeight); // suo } animation.setFillAfter(true); animation.setAnimationListener( new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) {} @Override public void onAnimationEnd(Animation animation) { clearAnimation(); mAnimating = false; if (mListener != null) {} } @Override public void onAnimationRepeat(Animation animation) {} }); clearAnimation(); startAnimation(animation); }
public Void call() { Animation myFadeInAnimation = AnimationUtils.loadAnimation(v.getContext(), R.anim.player_fade_in); myFadeInAnimation.setFillAfter(true); v.startAnimation(myFadeInAnimation); return null; }
public void moverLogo() { Animation mover; mover = AnimationUtils.loadAnimation(this.getApplicationContext(), R.anim.mover); mover.reset(); mover.setFillAfter(true); imgLogo.startAnimation(mover); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); final Window window = getWindow(); // 获取当前的窗体对象 window.setFlags( WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); // 隐藏了状态栏 requestWindowFeature(Window.FEATURE_NO_TITLE); // 隐藏了标题栏 setContentView(R.layout.welcome_view); iv_login = (ImageView) findViewById(R.id.iv_toMain); // 查找到对应的ImageView iv_login2 = (ImageView) findViewById(R.id.iv_toMain2); iv_login3 = (ImageView) findViewById(R.id.iv_toMain3); iv_login.setImageResource(R.drawable.iv_load); // 注意drawable中的图片的name必须是小写字母 iv_login2.setImageResource(R.drawable.iv_load); iv_login3.setImageResource(R.drawable.iv_load); a = AnimationUtils.loadAnimation(this, R.anim.ha); a2 = AnimationUtils.loadAnimation(this, R.anim.ha2); a3 = AnimationUtils.loadAnimation(this, R.anim.ha3); iv_login.startAnimation(a); iv_login2.startAnimation(a3); iv_login3.startAnimation(a2); a.setFillAfter(true); welcomeUI(); }
@Override public void onPageSelected(int arg0) { // TODO Auto-generated method stub Animation animation = null; switch (arg0) { case PAGE1: // 切换到页卡1 if (currentIndex == PAGE2) { // 如果之前显示的是页卡2 animation = new TranslateAnimation(0, -one, 0, 0); } else if (currentIndex == PAGE3) { // 如果之前显示的是页卡3 animation = new TranslateAnimation(one, -one, 0, 0); } break; case PAGE2: // 切换到页卡2 if (currentIndex == PAGE1) { // 如果之前显示的是页卡1 animation = new TranslateAnimation(-one, 0, 0, 0); } else if (currentIndex == PAGE3) { // 如果之前显示的是页卡3 animation = new TranslateAnimation(one, 0, 0, 0); } break; case PAGE3: // 切换到页卡3 if (currentIndex == PAGE1) { // 如果之前显示的是页卡1 animation = new TranslateAnimation(-one, one, 0, 0); } else if (currentIndex == PAGE2) { // 如果之前显示的是页卡2 animation = new TranslateAnimation(0, one, 0, 0); } break; default: break; } currentIndex = arg0; // 动画结束后,改变当前图片位置 animation.setFillAfter(true); // True:图片停在动画结束位置 animation.setDuration(300); cursor.startAnimation(animation); }
public static void fadeViewInOut(View view, long startDelay, long fadeTime, long stayTime) { AnimationSet set = new AnimationSet(false); Animation in = new AlphaAnimation(0.0f, 1.0f); in.setStartOffset(startDelay); in.setDuration(fadeTime); in.setFillAfter(false); in.setZAdjustment(Animation.ZORDER_TOP); set.addAnimation(in); Animation out = new AlphaAnimation(1.0f, 0.0f); out.setStartOffset(fadeTime + startDelay + stayTime); out.setDuration(fadeTime); out.setFillAfter(true); out.setZAdjustment(Animation.ZORDER_TOP); set.addAnimation(out); set.setFillAfter(true); view.startAnimation(set); }
private void rotate(float angle) { Animation animation = new RotateAnimation( 0.0f, angle, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); animation.setFillAfter(true); animation.setDuration(DURATION); imageViewExpand.startAnimation(animation); }
private void fadePage() { if (eink || pageNumberAnim == null) { pageNumberTextView.setVisibility(View.GONE); } else { pageNumberAnim.setStartOffset(0); pageNumberAnim.setFillAfter(true); pageNumberTextView.startAnimation(pageNumberAnim); } }
private Animation createScaleUpAnimationLocked( int transit, boolean enter, int appWidth, int appHeight) { Animation a = null; if (enter) { // Entering app zooms out from the center of the initial rect. float scaleW = mNextAppTransitionStartWidth / (float) appWidth; float scaleH = mNextAppTransitionStartHeight / (float) appHeight; Animation scale = new ScaleAnimation( scaleW, 1, scaleH, 1, computePivot(mNextAppTransitionStartX, scaleW), computePivot(mNextAppTransitionStartY, scaleH)); scale.setInterpolator(mDecelerateInterpolator); Animation alpha = new AlphaAnimation(0, 1); alpha.setInterpolator(mThumbnailFadeOutInterpolator); AnimationSet set = new AnimationSet(false); set.addAnimation(scale); set.addAnimation(alpha); set.setDetachWallpaper(true); a = set; } else if (transit == TRANSIT_WALLPAPER_INTRA_OPEN || transit == TRANSIT_WALLPAPER_INTRA_CLOSE) { // If we are on top of the wallpaper, we need an animation that // correctly handles the wallpaper staying static behind all of // the animated elements. To do this, will just have the existing // element fade out. a = new AlphaAnimation(1, 0); a.setDetachWallpaper(true); } else { // For normal animations, the exiting element just holds in place. a = new AlphaAnimation(1, 1); } // Pick the desired duration. If this is an inter-activity transition, // it is the standard duration for that. Otherwise we use the longer // task transition duration. final long duration; switch (transit) { case TRANSIT_ACTIVITY_OPEN: case TRANSIT_ACTIVITY_CLOSE: duration = mConfigShortAnimTime; break; default: duration = DEFAULT_APP_TRANSITION_DURATION; break; } a.setDuration(duration); a.setFillAfter(true); a.setInterpolator(mDecelerateInterpolator); a.initialize(appWidth, appHeight, appWidth, appHeight); return a; }
/** Flash camera preview, then display a white overlay. */ private void overlayPreview() { final Animation animation = new AlphaAnimation(1.0f, 0.8f); animation.setDuration(750); animation.setInterpolator(getActivity(), android.R.interpolator.decelerate_cubic); animation.setFillAfter(true); animation.setFillEnabled(true); mFlashView.setVisibility(View.VISIBLE); mFlashView.startAnimation(animation); }
protected Animation setAnimScale(float toX, float toY) { animationScale = new ScaleAnimation( 1f, toX, 1f, toY, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.45f); animationScale.setInterpolator( PathButtonActivity.this, anim.accelerate_decelerate_interpolator); animationScale.setDuration(500); animationScale.setFillAfter(false); return animationScale; }
public static void moveViewX(View view, int startDeltaX, int endDeltaY, long duration) { AnimationSet set = new AnimationSet(true); Animation move = new TranslateAnimation(startDeltaX, endDeltaY, 0, 0); move.setDuration(duration); move.setFillAfter(true); move.setZAdjustment(Animation.ZORDER_TOP); set.addAnimation(move); set.setFillAfter(true); view.startAnimation(set); }
/** * Create a pair of {@link FlipAnimation} that can be used to flip 3D transition from {@code * fromView} to {@code toView}. A typical use case is with {@link ViewAnimator} as an out and in * transition. * * <p>NOTE: Avoid using this method. Instead, use {@link #flipTransition}. * * @param fromView the view transition away from * @param toView the view transition to * @param dir the flip direction * @param duration the transition duration in milliseconds * @param interpolator the interpolator to use (pass {@code null} to use the {@link * AccelerateInterpolator} interpolator) * @return */ public static Animation[] flipAnimation( final View fromView, final View toView, FlipDirection dir, long duration) { Animation[] result = new Animation[2]; float centerY; centerY = fromView.getHeight() / 2.0f; Animation outFlip = new FlipAnimation( dir.getStartDegreeForFirstView(), dir.getEndDegreeForFirstView(), true, centerY, dir, fromView.getWidth()); outFlip.setDuration(duration); outFlip.setFillAfter(true); outFlip.setInterpolator(new AccelerateInterpolator()); AnimationSet outAnimation = new AnimationSet(true); outAnimation.addAnimation(outFlip); result[0] = outAnimation; Animation inFlip = new FlipAnimation( dir.getStartDegreeForSecondView(), dir.getEndDegreeForSecondView(), false, centerY, dir, fromView.getWidth()); inFlip.setDuration(duration); inFlip.setFillAfter(true); inFlip.setInterpolator(new DecelerateInterpolator()); inFlip.setStartOffset(duration); AnimationSet inAnimation = new AnimationSet(true); inAnimation.addAnimation(inFlip); result[1] = inAnimation; return result; }