zoukankan      html  css  js  c++  java
  • Android动画

    实现一个图片位移动画

            final int[] location = new int[2];
            v.getLocationOnScreen(location);
    
            int screenWidth = mShaPreferences.getInt("screenWidth", 0);
            int screenHeight = mShaPreferences.getInt("screenHeight", 0);
    
            FrameLayout.LayoutParams params = (android.widget.FrameLayout.LayoutParams) mImageAnim
                    .getLayoutParams();
            params.topMargin = location[1] - Util.px2dip(mContext, 20);
            params.leftMargin = screenWidth / 6;
            mImageAnim.setLayoutParams(params);
            mImageAnim.setVisibility(View.VISIBLE);
    
            int endX = screenWidth - Util.px2dip(mContext, 30);
            int endY = screenHeight - Util.px2dip(mContext, 20);
    
            AnimationSet set = new AnimationSet(false);
            TranslateAnimation translateAnimationX = new TranslateAnimation(0,
                    endX, 0, 0);
            translateAnimationX.setInterpolator(new LinearInterpolator());
            translateAnimationX.setRepeatCount(0);
            TranslateAnimation translateAnimationY = new TranslateAnimation(0, 0,
                    0, endY);
            translateAnimationY.setInterpolator(new AccelerateInterpolator());
            translateAnimationY.setRepeatCount(0);
    
            set.setAnimationListener(new Animation.AnimationListener() {
                @Override
                public void onAnimationStart(Animation animation) {
                }
    
                @Override
                public void onAnimationRepeat(Animation animation) {
                }
    
                @Override
                public void onAnimationEnd(Animation animation) {
                    mImageAnim.setVisibility(View.GONE);
                }
            });
    
            set.addAnimation(translateAnimationY);
            set.addAnimation(translateAnimationX);
            set.setDuration(500);
    
            mImageAnim.startAnimation(set);
  • 相关阅读:
    block、inline、inline-block
    js 的复制和引用 (传值和传址)
    俄罗斯方块和作品集
    js 连续赋值。。理解不了,先占坑
    8.7 jquery-dom manipulation
    08.04 对象构造方法
    对象的基本操作
    08.03 js _oop
    08.02 对象
    The 'Microsoft.ACE.OLEDB.12.0' provider is not registered on the local machine.
  • 原文地址:https://www.cnblogs.com/cc-Cheng/p/3303561.html
Copyright © 2011-2022 走看看