当前位置: 首页>>代码示例>>Java>>正文


Java TranslateAnimation类代码示例

本文整理汇总了Java中android.view.animation.TranslateAnimation的典型用法代码示例。如果您正苦于以下问题:Java TranslateAnimation类的具体用法?Java TranslateAnimation怎么用?Java TranslateAnimation使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


TranslateAnimation类属于android.view.animation包,在下文中一共展示了TranslateAnimation类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: ScanManager

import android.view.animation.TranslateAnimation; //导入依赖的package包/类
/**
 * 用于启动照相机扫描二维码,在activity的onCreate里面构造出来
 * 在activity的生命周期中调用此类相对应的生命周期方法
 *
 * @param activity      扫描的activity
 * @param scanPreview   预览的SurfaceView
 * @param scanContainer 扫描的布局,全屏布局
 * @param scanCropView  扫描的矩形区域
 * @param scanLine      扫描线
 */
public ScanManager(Activity activity, SurfaceView scanPreview, View scanContainer,
                   View scanCropView, ImageView scanLine, int scanMode, ScanListener listener) {
    this.activity = activity;
    this.scanPreview = scanPreview;
    this.scanContainer = scanContainer;
    this.scanCropView = scanCropView;
    this.scanLine = scanLine;
    this.listener = listener;
    this.scanMode = scanMode;
    //启动动画
    TranslateAnimation animation = new TranslateAnimation(Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT,
            0.9f);
    animation.setDuration(4500);
    animation.setRepeatCount(-1);
    animation.setRepeatMode(Animation.RESTART);
    scanLine.startAnimation(animation);

}
 
开发者ID:StickyTolt,项目名称:ForeverLibrary,代码行数:29,代码来源:ScanManager.java

示例2: translateHeader

import android.view.animation.TranslateAnimation; //导入依赖的package包/类
/**
 * Translates the adapter in Y
 *
 * @param of offset in px
 */
public void translateHeader(float of) {
    float ofCalculated = of * mScrollMultiplier;
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB && of < mHeader.getHeight()) {
        mHeader.setTranslationY(ofCalculated);
    } else if (of < mHeader.getHeight()) {
        TranslateAnimation anim = new TranslateAnimation(0, 0, ofCalculated, ofCalculated);
        anim.setFillAfter(true);
        anim.setDuration(0);
        mHeader.startAnimation(anim);
    }
    mHeader.setClipY(Math.round(ofCalculated));
    if (mParallaxScroll != null) {
        final RecyclerView.ViewHolder holder = mRecyclerView.findViewHolderForAdapterPosition(0);
        float left;
        if (holder != null) {
            left = Math.min(1, ((ofCalculated) / (mHeader.getHeight() * mScrollMultiplier)));
        }else {
            left = 1;
        }
        mParallaxScroll.onParallaxScroll(left, of, mHeader);
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:28,代码来源:UltimateRecyclerView.java

示例3: ScanManager

import android.view.animation.TranslateAnimation; //导入依赖的package包/类
/**
 * 用于启动照相机扫描二维码,在activity的onCreate里面构造出来
 * 在activity的生命周期中调用此类相对应的生命周期方法
 * @param activity   扫描的activity
 * @param scanPreview  预览的SurfaceView
 * @param scanContainer  扫描的布局,全屏布局
 * @param scanCropView  扫描的矩形区域
 * @param scanLine  扫描线
 * 
 * 
 */
public ScanManager(Activity activity, SurfaceView scanPreview, View scanContainer,
                      View scanCropView, ImageView scanLine, int scanMode, ScanListener listener) {
	this.activity=activity;
	this.scanPreview=scanPreview;
	this.scanContainer=scanContainer;
	this.scanCropView=scanCropView;
	this.scanLine=scanLine;
	this.listener=listener;
	this.scanMode=scanMode;
	//启动动画
	TranslateAnimation animation = new TranslateAnimation(Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT,
			0.9f);
	animation.setDuration(4500);
	animation.setRepeatCount(-1);
	animation.setRepeatMode(Animation.RESTART);
	scanLine.startAnimation(animation);
	
}
 
开发者ID:AnyRTC,项目名称:anyRTC-RTCP-Android,代码行数:30,代码来源:ScanManager.java

示例4: createOptionDisappearAnimation

import android.view.animation.TranslateAnimation; //导入依赖的package包/类
@Override
public Animation createOptionDisappearAnimation(OptionButton optionButton, int index) {
    AnimationSet animationSet = new AnimationSet(true);
    TranslateAnimation translateAnimation= new TranslateAnimation(
            0
            ,getYMenuButton().getX() - optionButton.getX()
            ,0
            ,getYMenuButton().getY() - optionButton.getY()
    );
    translateAnimation.setDuration(getOptionSD_AnimationDuration());
    AlphaAnimation alphaAnimation = new AlphaAnimation(1,0);
    alphaAnimation.setDuration(getOptionSD_AnimationDuration());
    animationSet.addAnimation(translateAnimation);
    animationSet.addAnimation(alphaAnimation);
    //为不同的Option设置延时
    if (index % 2 == 0) {
        animationSet.setStartOffset(getOptionSD_AnimationDuration()/2);
    }
    return animationSet;
}
 
开发者ID:totond,项目名称:YMenuView,代码行数:21,代码来源:Circle8YMenu.java

示例5: showTipViewAndDelayClose

import android.view.animation.TranslateAnimation; //导入依赖的package包/类
public void showTipViewAndDelayClose(String tip) {
    tipView.setText(tip);
    Animation mShowAction = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0.0f,
            Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF,
            -1.0f, Animation.RELATIVE_TO_SELF, 0.0f);
    mShowAction.setDuration(500);
    tipView.startAnimation(mShowAction);
    tipView.setVisibility(View.VISIBLE);

    tipView.postDelayed(new Runnable() {
        @Override
        public void run() {
            Animation mHiddenAction = new TranslateAnimation(Animation.RELATIVE_TO_SELF,
                    0.0f, Animation.RELATIVE_TO_SELF, 0.0f,
                    Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF,
                    -1.0f);
            mHiddenAction.setDuration(500);
            tipView.startAnimation(mHiddenAction);
            tipView.setVisibility(View.GONE);
        }
    }, 2200);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:23,代码来源:EasyRecyclerView.java

示例6: initAnimation

import android.view.animation.TranslateAnimation; //导入依赖的package包/类
private void initAnimation() {
    paint.setStrokeWidth(getHeight() * 0.01f);
    paint.setAntiAlias(true);
    paint.setDither(true);
    paint.setColor(Color.argb(248, 255, 255, 255));
    paint.setStrokeWidth(20f);
    paint.setStyle(Paint.Style.STROKE);
    paint.setStrokeJoin(Paint.Join.ROUND);
    paint.setStrokeCap(Paint.Cap.ROUND);

    paintGlow.set(paint);
    paintGlow.setColor(Color.argb(235, 74, 138, 255));
    paintGlow.setStrokeWidth(30f);
    paintGlow.setMaskFilter(new BlurMaskFilter(15, BlurMaskFilter.Blur.NORMAL));

    float deltaY = (CameraOverlayView.PADDING * 2) * getHeight();
    Log.i(TAG, String.format("Delta Y : %s", deltaY));

    TranslateAnimation mAnimation = new TranslateAnimation(0f, 0f, 0f, deltaY);
    mAnimation.setDuration(3000);
    mAnimation.setRepeatCount(-1);
    mAnimation.setRepeatMode(Animation.REVERSE);
    mAnimation.setInterpolator(new AccelerateDecelerateInterpolator());
    setAnimation(mAnimation);
}
 
开发者ID:jorenham,项目名称:fingerblox,代码行数:26,代码来源:ScannerOverlayView.java

示例7: translateAlphaFinishAnimation

import android.view.animation.TranslateAnimation; //导入依赖的package包/类
/**
 * 结束时的动画 平移到底部
 */
public static Animation translateAlphaFinishAnimation() {
    TranslateAnimation translateAnimation = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0, Animation.RELATIVE_TO_SELF, 0f,
            Animation.RELATIVE_TO_SELF, 0f, Animation.RELATIVE_TO_SELF, 1f);
    AlphaAnimation alphaAnimation = new AlphaAnimation(1, 0);
    setDefaultConfig(translateAnimation, true);
    setDefaultConfig(alphaAnimation, true);

    translateAnimation.setDuration(DEFAULT_DIALOG_FINISH_ANIM_TIME);
    alphaAnimation.setDuration(DEFAULT_DIALOG_FINISH_ANIM_TIME);

    AnimationSet animationSet = new AnimationSet(false);
    animationSet.addAnimation(alphaAnimation);
    animationSet.addAnimation(translateAnimation);
    return animationSet;
}
 
开发者ID:angcyo,项目名称:RLibrary,代码行数:19,代码来源:AnimUtil.java

示例8: onCreate

import android.view.animation.TranslateAnimation; //导入依赖的package包/类
@Override
public void onCreate(Bundle icicle) {
    super.onCreate(icicle);

    Window window = getWindow();
    window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
    setContentView(R.layout.activity_scan);

    scanPreview = (SurfaceView) findViewById(R.id.capture_preview);
    scanContainer = (RelativeLayout) findViewById(R.id.capture_container);
    scanCropView = (RelativeLayout) findViewById(R.id.capture_crop_view);
    scanLine = (ImageView) findViewById(R.id.capture_scan_line);

    inactivityTimer = new InactivityTimer(this);
    beepManager = new BeepManager(this);

    TranslateAnimation animation = new TranslateAnimation(Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, 0.9f);
    animation.setDuration(4500);
    animation.setRepeatCount(-1);
    animation.setRepeatMode(Animation.RESTART);
    scanLine.startAnimation(animation);

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

}
 
开发者ID:TonnyL,项目名称:Espresso,代码行数:28,代码来源:CaptureActivity.java

示例9: startAnim

import android.view.animation.TranslateAnimation; //导入依赖的package包/类
private void startAnim(View widget) {
    int distance = widget.getHeight();
    widget.setVisibility(0);
    this.mFloatLayout.setVisibility(0);
    AlphaAnimation alphaAnimation = new AlphaAnimation(0.0f, 1.0f);
    alphaAnimation.setDuration(200);
    alphaAnimation.setStartOffset(200);
    this.mFloatLayout.setAnimation(alphaAnimation);
    this.mAnimation = new TranslateAnimation(0.0f, 0.0f, (float) distance, 0.0f);
    this.mAnimation.setDuration(200);
    this.mAnimation.setStartOffset(200);
    widget.setAnimation(this.mAnimation);
    this.mAnimation.start();
    alphaAnimation.start();
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:16,代码来源:FeedBackAnimFragment.java

示例10: loadLayoutAnimation

import android.view.animation.TranslateAnimation; //导入依赖的package包/类
/**
 * 对话框的布局动画
 */
@Override
public Animation loadLayoutAnimation() {
    if (layoutAnim) {
        if (layoutAnimation == null) {
            TranslateAnimation translateAnimation = new TranslateAnimation(
                    Animation.RELATIVE_TO_PARENT, 0f, Animation.RELATIVE_TO_PARENT, 0f,
                    Animation.RELATIVE_TO_PARENT, 1f, Animation.RELATIVE_TO_PARENT, 0f);
            setDefaultConfig(translateAnimation, false);
            translateAnimation.setDuration(160);
            return translateAnimation;
        } else {
            return layoutAnimation;
        }
    }
    return null;
}
 
开发者ID:angcyo,项目名称:RLibrary,代码行数:20,代码来源:UIIDialogImpl.java

示例11: display

import android.view.animation.TranslateAnimation; //导入依赖的package包/类
public void display(float x) {
  this.startPositionX = x;
  this.lastPositionX  = x;

  recordButtonFab.setVisibility(View.VISIBLE);

  float translation = ViewCompat.getLayoutDirection(recordButtonFab) ==
      ViewCompat.LAYOUT_DIRECTION_LTR ? -.25f : .25f;

  AnimationSet animation = new AnimationSet(true);
  animation.addAnimation(new TranslateAnimation(Animation.RELATIVE_TO_SELF, translation,
                                                Animation.RELATIVE_TO_SELF, translation,
                                                Animation.RELATIVE_TO_SELF, -.25f,
                                                Animation.RELATIVE_TO_SELF, -.25f));

  animation.addAnimation(new ScaleAnimation(.5f, 1f, .5f, 1f,
                                            Animation.RELATIVE_TO_SELF, .5f,
                                            Animation.RELATIVE_TO_SELF, .5f));

  animation.setFillBefore(true);
  animation.setFillAfter(true);
  animation.setDuration(ANIMATION_DURATION);
  animation.setInterpolator(new OvershootInterpolator());

  recordButtonFab.startAnimation(animation);
}
 
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:27,代码来源:MicrophoneRecorderView.java

示例12: moveTo

import android.view.animation.TranslateAnimation; //导入依赖的package包/类
public void moveTo(float x) {
  this.lastPositionX = x;

  float offset          = getOffset(x);
  int   widthAdjustment = getWidthAdjustment();

  Animation translateAnimation = new TranslateAnimation(Animation.ABSOLUTE, widthAdjustment + offset,
                                                        Animation.ABSOLUTE, widthAdjustment + offset,
                                                        Animation.RELATIVE_TO_SELF, -.25f,
                                                        Animation.RELATIVE_TO_SELF, -.25f);

  translateAnimation.setDuration(0);
  translateAnimation.setFillAfter(true);
  translateAnimation.setFillBefore(true);

  recordButtonFab.startAnimation(translateAnimation);
}
 
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:18,代码来源:MicrophoneRecorderView.java

示例13: onCreate

import android.view.animation.TranslateAnimation; //导入依赖的package包/类
@Override
public void onCreate(Bundle icicle) {
    super.onCreate(icicle);

    Window window = getWindow();
    window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
    setContentView(R.layout.activity_capture);

    scanPreview = (SurfaceView) findViewById(R.id.capture_preview);
    scanContainer = (RelativeLayout) findViewById(R.id.capture_container);
    scanCropView = (RelativeLayout) findViewById(R.id.capture_crop_view);
    scanLine = (ImageView) findViewById(R.id.capture_scan_line);

    inactivityTimer = new InactivityTimer(this);
    beepManager = new BeepManager(this);

    TranslateAnimation animation = new TranslateAnimation(Animation.RELATIVE_TO_PARENT, 0.0f, Animation
            .RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT,
            0.9f);
    animation.setDuration(4500);
    animation.setRepeatCount(-1);
    animation.setRepeatMode(Animation.RESTART);
    scanLine.startAnimation(animation);
}
 
开发者ID:alibaba,项目名称:LuaViewPlayground,代码行数:25,代码来源:CaptureActivity.java

示例14: adjustSizes

import android.view.animation.TranslateAnimation; //导入依赖的package包/类
private void adjustSizes(boolean isAnimated) {
    int width = getWidth();
    if (width > 0 && this.items != null) {
        LayoutParams viewLayoutParams = (LayoutParams) this.currentView.getLayoutParams();
        viewLayoutParams.width = width / this.items.length;
        this.currentView.setLayoutParams(viewLayoutParams);
        if (!this.inAnimation) {
            if (isAnimated) {
                this.inAnimation = true;
                TranslateAnimation animation = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0,
                        Animation.RELATIVE_TO_SELF, this.currentIndex - this.lastIndex, 0, 0, 0, 0);
                animation.setDuration(300);
                animation.setAnimationListener(this);
                this.currentView.startAnimation(animation);
                return;
            }
            viewLayoutParams.leftMargin = this.currentIndex * viewLayoutParams.width;
            this.currentView.setLayoutParams(viewLayoutParams);
        }
    }
}
 
开发者ID:amspayam,项目名称:PDialogs-Android,代码行数:22,代码来源:SegmentController.java

示例15: boundBack

import android.view.animation.TranslateAnimation; //导入依赖的package包/类
/**
 * 将内容布局移动到原位置 可以在UP事件中调用, 也可以在其他需要的地方调用, 如手指移动到当前ScrollView外时
 */
private void boundBack() {

  if (!isMoved) {
    return; // 如果没有移动布局, 则跳过执行
  }
  // 开启动画
  TranslateAnimation anim = new TranslateAnimation(0, 0, contentView.getTop(), originalRect.top);
  anim.setDuration(ANIM_TIME);
  contentView.startAnimation(anim);
  // 设置回到正常的布局位置
  contentView.layout(originalRect.left, originalRect.top, originalRect.right,
      originalRect.bottom);
  // 将标志位设回false
  canPullDown = false;
  canPullUp = false;
  isMoved = false;
}
 
开发者ID:MUFCRyan,项目名称:BilibiliClient,代码行数:21,代码来源:SpringScrollView.java


注:本文中的android.view.animation.TranslateAnimation类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。