當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。