Java Code Examples for android.widget.TextView#startAnimation()

The following examples show how to use android.widget.TextView#startAnimation() . These examples are extracted from open source projects. 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
/**
 * Start Loop animation on given list of characters
 */
public long applyLoopAnimation(List<TextView> targetList) {
    long duration = (long) (CHARACTER_ANIM_DURATION * 5f);
    for (final TextView target : targetList) {
        AnimationSet set = new AnimationSet(true);
        if (headerLoopAnim == HeaderLoopAnim.ZOOM) {
            addLoopScaleAnimations(duration, set);
        } else if (headerLoopAnim == HeaderLoopAnim.FADE) {
            addLoopFadeAnimations(duration, set);
        }
        target.startAnimation(set);
    }

    // loop anim iteration
    currentLoopIteration = (currentLoopIteration + 1) % headerLoopAnimIteration;
    return (long) ((duration * 2.1f) + 300);
}
 
Example 2
Source Project: ToDay   File: ToDayStateFragment.java    License: MIT License 6 votes vote down vote up
/**
 * Adds completed time to an overflow variable overTime.
 *
 * Resets progress bar, begins a new timer with the
 * @param minsToExtend
 */
public void extendTime(int minsToExtend) {
    overTime = overTime + elementTimer.getTimeFinishedInMilliSecs();
    int millisToExtend = AppUtils.minsToMillis(minsToExtend);


    progress = AppUtils.millisToSecs(millisToExtend);

    progressBar.setMax(progress);
    progress = progressBar.getMax();
    progressBar.setProgress(progress);

    elementTimer= new ElementTimer(millisToExtend, 1000);
    startTimerOnUi();

    Animation fadeout = AnimationUtils.loadAnimation(getActivity(),android.R.anim.fade_out);
    TextView notFinished = (TextView) getView().findViewById(R.id.fragment_fe_not_finished);
    notFinished.startAnimation(fadeout);
    notFinished.setVisibility(View.INVISIBLE);
}
 
Example 3
Source Project: ToDay   File: ToDayStateFragment.java    License: MIT License 6 votes vote down vote up
/**
 * Produces animation, sets text to finish
 */
@Override
public void onFinish() {
    if (activityStateFlag.equals(AppConstants.FS_NOTIFICATION_ACTIVE)) {
        mNotifyMgr.notify(
                AppConstants.FLOW_STATE_NOTIFICATION_ID,
                mNotify
                        .setContentText(
                                getString(R.string.fs_task_finish_msg)
                        )
                        .setDefaults(Notification.DEFAULT_VIBRATE | Notification.DEFAULT_LIGHTS)
                        .build()
        );
    }
    progressBar.setProgress(0);
    Animation fadeInAnimation = AnimationUtils.loadAnimation(getContext(), android.R.anim.fade_in);
    timeDisplay.setText(getString(R.string.fs_task_finish_msg));
    timeDisplay.setAnimation(fadeInAnimation);

    TextView notFinished = (TextView) getView().findViewById(R.id.fragment_fe_not_finished);
    notFinished.setVisibility(View.VISIBLE);
    notFinished.startAnimation(fadeInAnimation);
}
 
Example 4
Source Project: Floo   File: WebActivity.java    License: Apache License 2.0 6 votes vote down vote up
@Override
@SuppressLint("SetJavaScriptEnabled")
protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_web);
  WebView webView = (WebView) findViewById(R.id.web_view);
  String url = getIntent().getStringExtra(URL);
  if (url == null && getIntent().getData() != null) {
    url = getIntent().getData().getQueryParameter(URL);
  }
  if (url == null) {
    finish();
  }
  webView.setWebViewClient(new InnerWebViewClient());
  webView.getSettings().setJavaScriptEnabled(true);
  webView.loadUrl(url);

  loading = (TextView) findViewById(R.id.loading);
  Animation animation = new ScaleAnimation(1.0f, 1.2f, 1.0f, 1.2f,
      Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
  animation.setRepeatMode(Animation.REVERSE);
  animation.setRepeatCount(Animation.INFINITE);
  animation.setDuration(500);
  loading.startAnimation(animation);
  setTitle(url);
}
 
Example 5
@MainThread
public void append(int value) {
  if (index >= codes.size()) return;

  setInactive(containers);
  setActive(containers.get(index));

  TextView codeView = codes.get(index++);

  Animation translateIn = new TranslateAnimation(0, 0, codeView.getHeight(), 0);
  translateIn.setInterpolator(new OvershootInterpolator());
  translateIn.setDuration(500);

  Animation fadeIn = new AlphaAnimation(0, 1);
  fadeIn.setDuration(200);

  AnimationSet animationSet = new AnimationSet(false);
  animationSet.addAnimation(fadeIn);
  animationSet.addAnimation(translateIn);
  animationSet.reset();
  animationSet.setStartTime(0);

  codeView.setText(String.valueOf(value));
  codeView.clearAnimation();
  codeView.startAnimation(animationSet);

  if (index == codes.size() && listener != null) {
    listener.onCodeComplete(Stream.of(codes).map(TextView::getText).collect(Collectors.joining()));
  }
}
 
Example 6
protected void hideCharInserts() {
if (!(keyboardVisible && charInserts)) {
	// No need to hide them if they're already hidden
	return;
}

TextView messageView = findViewById(R.id.message);
HorizontalScrollView charInsertTray = findViewById(R.id.char_insert_tray);

View buffer = findViewById(R.id.buffer);
View sep = findViewById(R.id.toggle_char_inserts_separator);
View wrapper = findViewById(R.id.toggle_wrapper);

toggleCharInserts.setImageResource(messageType != MessageType.MESSAGE ? R.drawable.ic_caret_left_white : R.drawable.ic_caret_left_black);
toggleProblemOverview.setImageResource(messageType != MessageType.MESSAGE ? R.drawable.problem_overview_white_unfilled : R.drawable.problem_overview_black_unfilled);

int total = buffer.getWidth() - sep.getWidth() - wrapper.getWidth();

RotateAnimation rotate = new RotateAnimation(180f, 360f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
rotate.setInterpolator(new AccelerateDecelerateInterpolator());
rotate.setRepeatCount(0);
rotate.setDuration(200);

messageView.startAnimation(new ResizeAnimation<LinearLayout>(messageView, 0, buffer.getHeight(), total, buffer.getHeight()));
charInsertTray.startAnimation(new ResizeAnimation<LinearLayout>(charInsertTray, ResizeAnimation.DEFAULT, ResizeAnimation.DEFAULT, 0, ResizeAnimation.DEFAULT));
toggleCharInserts.startAnimation(rotate);

charInserts = false;
  }
 
Example 7
private void showTipsAnimation(TextView newsView) {
    AlphaAnimation alphaAnimation = new AlphaAnimation(1.0f, 0.1f);
    alphaAnimation.setDuration(1100);
    alphaAnimation.setRepeatMode(Animation.RESTART);
    alphaAnimation.setRepeatCount(Animation.INFINITE);
    newsView.startAnimation(alphaAnimation);
}
 
Example 8
Source Project: NewFastFrame   File: SplashActivity.java    License: Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_splash_main);
    StatusBarUtil.setTranslucentForImageViewInFragment(this, 0, null);
    time = findViewById(R.id.tv_activity_splash_main_time);
    TextView title = findViewById(R.id.tv_activity_splash_main_title);
    Animation animation = AnimationUtils.loadAnimation(SplashActivity.this, R.anim.splash_top_in);
    animation.setAnimationListener(this);
    title.startAnimation(animation);
}
 
Example 9
Source Project: Modularity   File: MainActivity.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 显示Toolbar的退出tip
 */
public void showExitTip() {
    TextView view = (TextView) findViewById(R.id.titlebar_text_exittip);
    view.setVisibility(View.VISIBLE);
    Animation a = AnimationUtil.getTranslateAnimation(0f, 0f, -getToolbar().getHeight(), 0f, 300);
    view.startAnimation(a);
}
 
Example 10
Source Project: Modularity   File: MainActivity.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 显示Toolbar的退出tip
 */
public void showExitTip() {
    TextView view = (TextView) findViewById(R.id.titlebar_text_exittip);
    view.setVisibility(View.VISIBLE);
    Animation a = AnimationUtil.getTranslateAnimation(0f, 0f, -getToolbar().getHeight(), 0f, 300);
    view.startAnimation(a);
}
 
Example 11
Source Project: Modularity   File: MainActivity.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 显示Toolbar的退出tip
 */
public void showExitTip() {
    TextView view = (TextView) findViewById(R.id.titlebar_text_exittip);
    view.setVisibility(View.VISIBLE);
    Animation a = AnimationUtil.getTranslateAnimation(0f, 0f, -getToolbar().getHeight(), 0f, 300);
    view.startAnimation(a);
}
 
Example 12
Source Project: android-tv-launcher   File: AppFragment.java    License: MIT License 5 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = LayoutInflater.from(getActivity()).inflate(R.layout.fragment_app, null);
    mViewPager = (ViewPager) view.findViewById(R.id.app_view_pager);
    pointer = (TextView) view.findViewById(R.id.app_pointer);

    initAnimation();
    pointer.startAnimation(rotation);

    initAllApp();
    mViewPager.setOnPageChangeListener(pageChangeListener);
    return view;
}
 
Example 13
Source Project: android-apps   File: MainActivity.java    License: MIT License 5 votes vote down vote up
@SuppressLint("NewApi")
@Override
protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	setContentView(R.layout.activity_main);
	
	tv1 = (TextView) findViewById(R.id.tv1);
	tv2 = (TextView) findViewById(R.id.tv2);
	tv3 = (TextView) findViewById(R.id.tv3);
	tv4 = (TextView) findViewById(R.id.tv4);
	
	
	if( Build.VERSION.SDK_INT < 11 ){
		RotateAnimation ra = new RotateAnimation(0, 90);
		ra.setDuration(100);
		ra.setFillAfter(true);
		
		tv1.startAnimation(ra);
		tv2.startAnimation(ra);
		tv3.startAnimation(ra);
		tv4.startAnimation(ra);
		
	} else{
		try{
			tv1.setRotation(90);
			tv2.setRotation(45);
			tv3.setRotation(180);
			tv4.setRotation(-90);
		} catch(Exception e){
			e.printStackTrace();
		}
	}
	
	
}
 
Example 14
Source Project: android-apps   File: MainActivity.java    License: MIT License 5 votes vote down vote up
@SuppressLint("NewApi")
@Override
protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	setContentView(R.layout.activity_main);
	
	tv1 = (TextView) findViewById(R.id.tv1);
	tv2 = (TextView) findViewById(R.id.tv2);
	tv3 = (TextView) findViewById(R.id.tv3);
	tv4 = (TextView) findViewById(R.id.tv4);
	
	
	if( Build.VERSION.SDK_INT < 11 ){
		RotateAnimation ra = new RotateAnimation(0, 90);
		ra.setDuration(100);
		ra.setFillAfter(true);
		
		tv1.startAnimation(ra);
		tv2.startAnimation(ra);
		tv3.startAnimation(ra);
		tv4.startAnimation(ra);
		
	} else{
		try{
			tv1.setRotation(90);
			tv2.setRotation(45);
			tv3.setRotation(180);
			tv4.setRotation(-90);
		} catch(Exception e){
			e.printStackTrace();
		}
	}
	
	
}
 
Example 15
Source Project: YCAudioPlayer   File: ShareDialog.java    License: Apache License 2.0 4 votes vote down vote up
/**
 * show 弹出动画
 * @param textView                      textView
 */
private void showBottomInAnimation(TextView textView) {
    textView.setVisibility(View.VISIBLE);
    textView.startAnimation(AnimationUtils.loadAnimation(mContext, R.anim.share_bottom_in));
}
 
Example 16
/**
 * Start animations on characters
 */
public long applyTextAnimation(final TextView target) {

    final long duration = (long) (CHARACTER_ANIM_DURATION * 2.1f);

    if (isColorAnimEnable && colorAnimationArray != null) {
        final ValueAnimator colorAnimation = ValueAnimator.ofObject(new ArgbEvaluator(), originalColor, colorAnimationArray[colorIndex]);
        colorAnimation.setDuration(duration);
        colorAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
            @Override
            public void onAnimationUpdate(ValueAnimator animator) {
                target.setTextColor((Integer) animator.getAnimatedValue());
            }
        });
        colorAnimation.addListener(new AnimatorListenerAdapter() {
            @Override
            public void onAnimationEnd(Animator animation) {
                super.onAnimationEnd(animation);
                target.setTextColor(originalColor);
            }
        });
        colorAnimation.start();

        // loop though color array
        colorIndex = (colorIndex + 1) % colorAnimationArray.length;
    }

    AnimationSet set = new AnimationSet(true);
    if (headerTextAnim == HeaderTextAnim.ROTATE_CW) {
        ROTATION_ANGLE = 20.0f;
        addTextRotateAnimations(set);
    } else if (headerTextAnim == HeaderTextAnim.ROTATE_ACW) {
        ROTATION_ANGLE = -20.0f;
        addTextRotateAnimations(set);
    } else if (headerTextAnim == HeaderTextAnim.FADE) {
        addTextFadeAnimations(set);
    } else if (headerTextAnim == HeaderTextAnim.ZOOM) {
        addTextZoomAnimations(set);
    }
    target.startAnimation(set);

    // text anim iteration
    currentTextIteration = (currentTextIteration + 1) % headerTextAnimIteration;

    return duration + CHARACTER_ANIM_DURATION;
}
 
Example 17
Source Project: iMoney   File: GestureVerifyActivity.java    License: Apache License 2.0 4 votes vote down vote up
private void setUpViews() {
    mTopLayout = (RelativeLayout) findViewById(R.id.top_layout);
    mTextTitle = (TextView) findViewById(R.id.text_title);
    mTextCancel = (TextView) findViewById(R.id.text_cancel);
    mImgUserLogo = (ImageView) findViewById(R.id.user_logo);
    mTextPhoneNumber = (TextView) findViewById(R.id.text_phone_number);
    mTextTip = (TextView) findViewById(R.id.text_tip);
    mGestureContainer = (FrameLayout) findViewById(R.id.gesture_container);
    mTextForget = (TextView) findViewById(R.id.text_forget_gesture);
    mTextOther = (TextView) findViewById(R.id.text_other_account);

    String inputCode = mSharedPreferences.getString("inputCode", "1235789");
    // 初始化一个显示各个点的viewGroup
    mGestureContentView = new GestureContentView(this, true, inputCode,
            new GestureDrawline.GestureCallBack() {

                @Override
                public void onGestureCodeInput(String inputCode) {

                }

                @Override
                public void checkedSuccess() {

                    mGestureContentView.clearDrawlineState(0L);

                    Toast.makeText(GestureVerifyActivity.this, "密码正确", Toast.LENGTH_SHORT).show();

                    GestureVerifyActivity.this.finish();
                }

                @Override
                public void checkedFail() {

                    mGestureContentView.clearDrawlineState(1300L);
                    mTextTip.setVisibility(View.VISIBLE);
                    mTextTip.setText(Html.fromHtml("<font color='#c70c1e'>密码错误</font>"));

                    // 左右移动动画
                    Animation shakeAnimation = AnimationUtils.loadAnimation(GestureVerifyActivity.this, R.anim.shake);
                    mTextTip.startAnimation(shakeAnimation);
                }
            });

    // 设置手势解锁显示到哪个布局里面
    mGestureContentView.setParentView(mGestureContainer);
}
 
Example 18
Source Project: iMoney   File: GestureEditActivity.java    License: Apache License 2.0 4 votes vote down vote up
private void setUpViews() {
    mTextTitle = (TextView) findViewById(R.id.text_title);
    mTextCancel = (TextView) findViewById(R.id.text_cancel);
    mTextReset = (TextView) findViewById(R.id.text_reset);
    mTextReset.setClickable(false);
    mLockIndicator = (LockIndicator) findViewById(R.id.lock_indicator);
    mTextTip = (TextView) findViewById(R.id.text_tip);
    mGestureContainer = (FrameLayout) findViewById(R.id.gesture_container);
    mSharedPreferences = this.getSharedPreferences("secret_protect", Context.MODE_PRIVATE);
    // 初始化一个显示各个点的viewGroup
    mGestureContentView = new GestureContentView(this, false, "", new GestureDrawline.GestureCallBack() {
        @Override
        public void onGestureCodeInput(String inputCode) {
            if (!isInputPassValidate(inputCode)) {
                mTextTip.setText(Html.fromHtml("<font color='#c70c1e'>最少链接4个点, 请重新输入</font>"));
                mGestureContentView.clearDrawlineState(0L);
                return;
            }

            if (mIsFirstInput) {
                mFirstPassword = inputCode;
                updateCodeList(inputCode);
                mGestureContentView.clearDrawlineState(0L);
                mTextReset.setClickable(true);
                mTextReset.setText(getString(R.string.reset_gesture_code));
            } else {

                if (inputCode.equals(mFirstPassword)) {
                    Toast.makeText(GestureEditActivity.this, "设置成功", Toast.LENGTH_SHORT).show();
                    mGestureContentView.clearDrawlineState(0L);
                    GestureEditActivity.this.finish();
                } else {
                    mTextTip.setText(Html.fromHtml("<font color='#c70c1e'>与上一次绘制不一致,请重新绘制</font>"));
                    // 左右移动动画
                    Animation shakeAnimation = AnimationUtils.loadAnimation(GestureEditActivity.this, R.anim.shake);
                    mTextTip.startAnimation(shakeAnimation);
                    // 保持绘制的线,1.5秒后清除
                    mGestureContentView.clearDrawlineState(1300L);
                }
            }

            mIsFirstInput = false;
        }

        @Override
        public void checkedSuccess() {

        }

        @Override
        public void checkedFail() {

        }
    });

    // 设置手势解锁显示到哪个布局里面
    mGestureContentView.setParentView(mGestureContainer);

    updateCodeList("");
}
 
Example 19
private void myCustomTextViewAnimation(TextView tv) {
    Animation animation = new TranslateAnimation(0, 0, 480, 0);
    animation.setDuration(3000);
    tv.startAnimation(animation);
}
 
Example 20
private void TextViewAnimation(TextView tv) {
    Animation animation = new AlphaAnimation(0, 1);
    animation.setStartOffset(1000);
    animation.setDuration(4500);
    tv.startAnimation(animation);
}