Java Code Examples for android.view.animation.TranslateAnimation#setRepeatMode()
The following examples show how to use
android.view.animation.TranslateAnimation#setRepeatMode() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CaptureActivity.java From ZXingProject with MIT License | 6 votes |
@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); }
Example 2
Source File: CaptureActivity.java From ZBarScanProj with MIT License | 6 votes |
private void initViews() { autoFocusHandler = new Handler(); mCameraManager = new CameraManager(this); try { mCameraManager.openDriver(); } catch (IOException e) { e.printStackTrace(); } mCamera = mCameraManager.getCamera(); mPreview = new CameraPreview(this, mCamera, previewCb, autoFocusCB); scanPreview.addView(mPreview); 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.85f); animation.setDuration(3000); animation.setRepeatCount(-1); animation.setRepeatMode(Animation.REVERSE); scanLine.startAnimation(animation); }
Example 3
Source File: MainActivity.java From Android-Basics-Codes with Artistic License 2.0 | 6 votes |
/** * λ�ƶ��� * * @param v */ public void translate(View v) { /* * ����1,����3������5������7�� ���ò��յ�ķ�ʽ������Լ���Animation.RELATIVE_TO_SELF * ����2��x����ʼ�ƶ���λ�� (0��ʾԭͼλ�����Ͻ�x�������) ����4��x��ֹͣ�ƶ���λ�ã�2��ʾ�ƶ�ԭͼ��ȵ������� * ����6��y����ʼ�ƶ���λ�� (0��ʾԭͼλ�����Ͻ�y�������) ����8��y��ֹͣ�ƶ���λ�ã�2��ʾ�ƶ�ԭͼ�߶ȵ������� */ TranslateAnimation tras = new TranslateAnimation( Animation.RELATIVE_TO_SELF, 0, Animation.RELATIVE_TO_SELF, 2, Animation.RELATIVE_TO_SELF, 0, Animation.RELATIVE_TO_SELF, 2); // ������ʾʱ�䳤�� tras.setDuration(2000); // �����ظ����� tras.setRepeatCount(2); // ���ö����ظ���ģʽ tras.setRepeatMode(Animation.REVERSE); // ��ImageView�ϲ��Ŷ��� iv.startAnimation(tras); }
Example 4
Source File: MainActivity.java From Android-Basics-Codes with Artistic License 2.0 | 6 votes |
public void translate(View v){ //����ƽ�Ʋ��䶯�� // TranslateAnimation ta = new TranslateAnimation(-100, 100, -50, 50); ta = new TranslateAnimation(Animation.RELATIVE_TO_SELF, -3, Animation.RELATIVE_TO_SELF, 3, Animation.RELATIVE_TO_SELF, 0, Animation.RELATIVE_TO_SELF, 0); //���ö�������ʱ�� ta.setDuration(2000); //�����ظ����Ŵ��� ta.setRepeatCount(1); //�����ظ�����ģʽ ta.setRepeatMode(Animation.REVERSE); //���ö���ͣ���ڽ���λ�� ta.setFillAfter(true); iv.startAnimation(ta); }
Example 5
Source File: PostFeedActivity.java From umeng_community_android with MIT License | 6 votes |
/** * 为话题提示VIew绑定动画</br> */ private void startAnimationForTopicTipView() { int timePiece = 500; int repeatCount = 4; int startDeny = 50; TranslateAnimation translateAnimation = new TranslateAnimation(0, 0, 10, 0); translateAnimation.setRepeatMode(Animation.REVERSE); // translateAnimation.setStartOffset(startDeny * repeatCount+timePiece); translateAnimation.setRepeatCount(Integer.MAX_VALUE); translateAnimation.setDuration(timePiece); AlphaAnimation alphaAnimationIn = new AlphaAnimation(0, 1.0f); alphaAnimationIn.setDuration(timePiece); alphaAnimationIn.setStartOffset(startDeny * repeatCount); AnimationSet animationSet = new AnimationSet(true); animationSet.addAnimation(alphaAnimationIn); animationSet.addAnimation(translateAnimation); // animationSet.addAnimation(alphaAnimationOut); // animationSet.setFillAfter(true); mTopicTipView.startAnimation(animationSet); }
Example 6
Source File: CaptureActivity.java From AirFree-Client with GNU General Public License v3.0 | 6 votes |
@Override public void onCreate(Bundle icicle) { requestWindowFeature(Window.FEATURE_NO_TITLE); 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); }
Example 7
Source File: ScanLoginActivity.java From Android with MIT License | 6 votes |
@Override public void initView() { mActivity = this; setViewFind(capturePreview, captureCropView, captureContainer); TranslateAnimation animation = new TranslateAnimation(Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, -1.0f, Animation.RELATIVE_TO_PARENT, 0.0f); animation.setDuration(1500); animation.setRepeatCount(-1); animation.setRepeatMode(Animation.RESTART); captureScanLine.startAnimation(animation); //setLineAnimation(captureScanLine); setPresenter(new ScanLoginPresenter(this)); presenter.start(); }
Example 8
Source File: CaptureActivity.java From ScanZbar with Apache License 2.0 | 6 votes |
private void initView() { 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); findViewById(R.id.capture_imageview_back).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { finish(); } }); isHasSurface = false; 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(3000); animation.setRepeatCount(-1); animation.setRepeatMode(Animation.RESTART); scanLine.startAnimation(animation); }
Example 9
Source File: CustomCaptureActvity.java From imsdk-android with MIT License | 6 votes |
private void initCamera() { autoFocusHandler = new Handler(); mCameraManager = new CameraManager(this); try { mCameraManager.openDriver(); } catch (Exception e) { LogUtil.e(TAG,"ERROR",e); finish(); } mCamera = mCameraManager.getCamera(); mPreview = new CameraPreview(this, mCamera, previewCb, autoFocusCB); scanPreview.addView(mPreview); 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.85f); animation.setDuration(3000); animation.setRepeatCount(-1); animation.setRepeatMode(Animation.REVERSE); scanLine.startAnimation(animation); }
Example 10
Source File: CommonViewAnimationActivity.java From Study_Android_Demo with Apache License 2.0 | 5 votes |
private Animation getTranslateAnimation() { TranslateAnimation translateAnimation = new TranslateAnimation(0, getWidth() * 2, 0, getHeight() * 2); translateAnimation.setDuration(2000); translateAnimation.setRepeatCount(2); translateAnimation.setFillAfter(true); translateAnimation.setFillBefore(false); translateAnimation.setRepeatMode(Animation.REVERSE); return translateAnimation; }
Example 11
Source File: CaptureActivity.java From AndroidWallet with GNU General Public License v3.0 | 5 votes |
/** * 开始扫码 */ @SuppressLint("NewApi") private void startScan() { inactivityTimer = new InactivityTimer(this); beepManager = new BeepManager(this); // 扫描线动画2(补间动画) translateAnimation = 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); translateAnimation.setDuration(4500); translateAnimation.setRepeatCount(-1); translateAnimation.setRepeatMode(Animation.RESTART); scanLine.startAnimation(translateAnimation); if (isPause) { objectAnimator.resume(); isPause = false; } else { objectAnimator.start(); } // CameraManager must be initialized here, not in onCreate(). This is necessary because we don't // want to open the camera driver and measure the screen size if we're going to show the help on // first launch. That led to bugs where the scanning rectangle was the wrong size and partially // off screen. cameraManager = new CameraManager(getApplication()); handler = null; if (isHasSurface) { // The activity was paused but not stopped, so the surface still exists. Therefore // surfaceCreated() won't be called, so init the camera here. initCamera(scanPreview.getHolder()); } else { // Install the callback and wait for surfaceCreated() to init the camera. scanPreview.getHolder().addCallback(this); } inactivityTimer.onResume(); }
Example 12
Source File: CommonViewAnimationActivity.java From Android-Animation-Set with Apache License 2.0 | 5 votes |
private Animation getTranslateAnimation() { TranslateAnimation translateAnimation = new TranslateAnimation(0, getWidth() * 2, 0, getHeight() * 2); translateAnimation.setDuration(2000); translateAnimation.setRepeatCount(2); translateAnimation.setFillAfter(true); translateAnimation.setFillBefore(false); translateAnimation.setRepeatMode(Animation.REVERSE); return translateAnimation; }
Example 13
Source File: GameActivity.java From SchoolQuest with GNU General Public License v3.0 | 5 votes |
private void setUpTextBoxArrowAnimation() { ImageView textBoxArrow = findViewById(R.id.textbox_box_arrow); TranslateAnimation textBoxArrowAnimation = new TranslateAnimation(TranslateAnimation.ABSOLUTE, 0f, TranslateAnimation.ABSOLUTE, 0f, TranslateAnimation.RELATIVE_TO_PARENT, 0f, TranslateAnimation.RELATIVE_TO_PARENT, 0.01f); textBoxArrowAnimation.setDuration(500); textBoxArrowAnimation.setRepeatCount(-1); textBoxArrowAnimation.setRepeatMode(Animation.RESTART); textBoxArrowAnimation.setInterpolator(new LinearInterpolator()); textBoxArrowAnimation.setFillAfter(true); textBoxArrow.setAnimation(textBoxArrowAnimation); }
Example 14
Source File: MiniGame.java From SchoolQuest with GNU General Public License v3.0 | 5 votes |
void setUpTextBoxArrowAnimation(ImageView textboxArrow) { TranslateAnimation textBoxArrowAnimation = new TranslateAnimation( TranslateAnimation.ABSOLUTE, 0f, TranslateAnimation.ABSOLUTE, 0f, TranslateAnimation.RELATIVE_TO_PARENT, 0f, TranslateAnimation.RELATIVE_TO_PARENT, 0.01f); textBoxArrowAnimation.setDuration(500); textBoxArrowAnimation.setRepeatCount(-1); textBoxArrowAnimation.setRepeatMode(Animation.RESTART); textBoxArrowAnimation.setInterpolator(new LinearInterpolator()); textBoxArrowAnimation.setFillAfter(true); textboxArrow.setAnimation(textBoxArrowAnimation); }
Example 15
Source File: CaptureActivity.java From gokit-android with MIT License | 4 votes |
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); /** * 设置为竖屏 */ if (getRequestedOrientation() != ActivityInfo.SCREEN_ORIENTATION_PORTRAIT) { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); } Window window = getWindow(); window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); setContentView(R.layout.activity_gos_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); TranslateAnimation animation = new TranslateAnimation(Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, -1.0f, Animation.RELATIVE_TO_PARENT, 0.0f); animation.setDuration(4500); animation.setRepeatCount(-1); animation.setRepeatMode(Animation.RESTART); scanLine.startAnimation(animation); btnCancel = (Button) findViewById(R.id.btn_cancel); ivReturn = (ImageView) findViewById(R.id.iv_return); OnClickListener myClick = new OnClickListener() { @Override public void onClick(View arg0) { CaptureActivity.this.finish(); } }; btnCancel.setOnClickListener(myClick); ivReturn.setOnClickListener(myClick); }
Example 16
Source File: CaptureActivity.java From GOpenSource_AppKit_Android_AS with MIT License | 4 votes |
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); /** * 设置为竖屏 */ if (getRequestedOrientation() != ActivityInfo.SCREEN_ORIENTATION_PORTRAIT) { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); } Window window = getWindow(); window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); setContentView(R.layout.activity_gos_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); TranslateAnimation animation = new TranslateAnimation(Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, -1.0f, Animation.RELATIVE_TO_PARENT, 0.0f); animation.setDuration(4500); animation.setRepeatCount(-1); animation.setRepeatMode(Animation.RESTART); scanLine.startAnimation(animation); btnCancel = (Button) findViewById(R.id.btn_cancel); ivReturn = (ImageView) findViewById(R.id.iv_return); OnClickListener myClick = new OnClickListener() { @Override public void onClick(View arg0) { CaptureActivity.this.finish(); } }; btnCancel.setOnClickListener(myClick); ivReturn.setOnClickListener(myClick); }
Example 17
Source File: QrCodeScanActivity.java From FamilyChat with Apache License 2.0 | 4 votes |
protected void initUI() { //全屏设置 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { View statusBar = findViewById(R.id.view_qrcode_actionbar_status); statusBar.setVisibility(View.VISIBLE); ViewGroup.LayoutParams layoutParams = statusBar.getLayoutParams(); layoutParams.height = OtherUtils.getStatusBarHeight(this); statusBar.setLayoutParams(layoutParams); } //闪光灯 mImgLight = (ImageView) findViewById(R.id.img_qrcode_light); mScanPreview = (SurfaceView) findViewById(R.id.capture_preview); mScanContainer = (RelativeLayout) findViewById(R.id.capture_container); mScanCropView = (RelativeLayout) findViewById(R.id.capture_crop_view); mScanLine = (ImageView) findViewById(R.id.capture_scan_line); //设置阴影 View shadowTop = findViewById(R.id.capture_mask_top); View shadowBottom = findViewById(R.id.capture_mask_bottom); View shadowLeft = findViewById(R.id.capture_mask_left); View shadowRight = findViewById(R.id.capture_mask_right); shadowTop.setAlpha(0.5f); shadowBottom.setAlpha(0.5f); shadowLeft.setAlpha(0.5f); shadowRight.setAlpha(0.5f); mInactivityTimer = new InactivityTimer(this); mBeepManager = 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.85f); animation.setDuration(2500); animation.setRepeatCount(-1); animation.setInterpolator(new AccelerateDecelerateInterpolator(QrCodeScanActivity.this, null)); animation.setRepeatMode(Animation.RESTART); mScanLine.startAnimation(animation); findViewById(R.id.ll_qrcode_actionbar_left_back).setOnClickListener(this); mImgLight.setOnClickListener(this); }
Example 18
Source File: CaptureActivity.java From Gizwits-SmartBuld_Android with MIT License | 4 votes |
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); /** * 设置为竖屏 */ if (getRequestedOrientation() != ActivityInfo.SCREEN_ORIENTATION_PORTRAIT) { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); } Window window = getWindow(); window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); setContentView(R.layout.activity_gos_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); TranslateAnimation animation = new TranslateAnimation(Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, -1.0f, Animation.RELATIVE_TO_PARENT, 0.0f); animation.setDuration(4500); animation.setRepeatCount(-1); animation.setRepeatMode(Animation.RESTART); scanLine.startAnimation(animation); btnCancel = (Button) findViewById(R.id.btn_cancel); ivReturn = (ImageView) findViewById(R.id.iv_return); OnClickListener myClick = new OnClickListener() { @Override public void onClick(View arg0) { CaptureActivity.this.finish(); } }; btnCancel.setOnClickListener(myClick); ivReturn.setOnClickListener(myClick); }
Example 19
Source File: MainActivity.java From Android-Basics-Codes with Artistic License 2.0 | 4 votes |
public void mahang (View view){ AnimationSet set = new AnimationSet(false); TranslateAnimation tras = new TranslateAnimation( Animation.RELATIVE_TO_SELF, 0, Animation.RELATIVE_TO_SELF, 2, Animation.RELATIVE_TO_SELF, 0, Animation.RELATIVE_TO_SELF, 2); // ������ʾʱ�䳤�� tras.setDuration(2000); // �����ظ����� tras.setRepeatCount(2); // ���ö����ظ���ģʽ tras.setRepeatMode(Animation.REVERSE); RotateAnimation rotate = new RotateAnimation(360, 0, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); // ������ʾʱ�䳤�� rotate.setDuration(2000); // �����ظ����� rotate.setRepeatCount(2); // ���ö����ظ���ģʽ rotate.setRepeatMode(Animation.REVERSE); ScaleAnimation scale = new ScaleAnimation(4f, 0.2f, 4f, 0.2f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); // ������ʾʱ�䳤�� scale.setDuration(2000); // �����ظ����� scale.setRepeatCount(2); // ���ö����ظ���ģʽ scale.setRepeatMode(Animation.REVERSE); Animation alpha = new AlphaAnimation(1f, 0.1f); // ������ʾʱ�䳤�� alpha.setDuration(2000); // �����ظ����� alpha.setRepeatCount(2); // ���ö����ظ���ģʽ alpha.setRepeatMode(Animation.REVERSE); set.addAnimation(tras); set.addAnimation(alpha); set.addAnimation(rotate); set.addAnimation(scale); // ��ImageView�ϲ��Ŷ��� iv.startAnimation(set); }
Example 20
Source File: MainActivity.java From Android-Basics-Codes with Artistic License 2.0 | 4 votes |
public void mahang (View view){ AnimationSet set = new AnimationSet(false); TranslateAnimation tras = new TranslateAnimation( Animation.RELATIVE_TO_SELF, 0, Animation.RELATIVE_TO_SELF, 2, Animation.RELATIVE_TO_SELF, 0, Animation.RELATIVE_TO_SELF, 2); // ������ʾʱ�䳤�� tras.setDuration(2000); // �����ظ����� tras.setRepeatCount(2); // ���ö����ظ���ģʽ tras.setRepeatMode(Animation.REVERSE); RotateAnimation rotate = new RotateAnimation(360, 0, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); // ������ʾʱ�䳤�� rotate.setDuration(2000); // �����ظ����� rotate.setRepeatCount(2); // ���ö����ظ���ģʽ rotate.setRepeatMode(Animation.REVERSE); ScaleAnimation scale = new ScaleAnimation(4f, 0.2f, 4f, 0.2f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); // ������ʾʱ�䳤�� scale.setDuration(2000); // �����ظ����� scale.setRepeatCount(2); // ���ö����ظ���ģʽ scale.setRepeatMode(Animation.REVERSE); Animation alpha = new AlphaAnimation(1f, 0.1f); // ������ʾʱ�䳤�� alpha.setDuration(2000); // �����ظ����� alpha.setRepeatCount(2); // ���ö����ظ���ģʽ alpha.setRepeatMode(Animation.REVERSE); set.addAnimation(tras); set.addAnimation(alpha); set.addAnimation(rotate); set.addAnimation(scale); // ��ImageView�ϲ��Ŷ��� iv.startAnimation(set); }