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

The following are Jave code examples for showing how to use startAnimation() of the android.widget.TextView class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: Mobile-phone-tracking-App   File: Splash.java   View Source Code Vote up 6 votes
@Override
protected void onCreate(Bundle savedInstanceState) {
	// TODO Auto-generated method stub
	super.onCreate(savedInstanceState);
setContentView(R.layout.activity_splash);
iv=(ImageView)findViewById(R.id.imageView1);
tv=(TextView)findViewById(R.id.textView1);
animFadeOut=AnimationUtils.loadAnimation(getApplicationContext(), R.anim.fade_out);
animfadein=AnimationUtils.loadAnimation(getApplicationContext(), R.anim.together);
animFadeOut.setAnimationListener(this);
animfadein.setAnimationListener(this);
iv.startAnimation(animfadein);
tv.startAnimation(animFadeOut);


h= new Handler();
h.postDelayed(new Runnable() {
	
	@Override
	public void run() {
		// TODO Auto-generated method stub
		finish();
		if(!bbp)
		{
			Intent intent =new Intent(Splash.this,MainActivity.class);
			Splash.this.startActivity(intent);
			
		}
		
		
		
		
	}
}, holding);
 
 }
 
Example 2
Project: AnimatedPullToRefresh-master   File: AnimationHelper.java   View Source Code Vote up 6 votes
/**
 * 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 3
Project: HiBangClient   File: WhatsnewDoor.java   View Source Code Vote up 6 votes
@Override
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.whats_door);
      
      mLeft = (ImageView)findViewById(R.id.imageLeft);
      mRight = (ImageView)findViewById(R.id.imageRight);
      mText = (TextView)findViewById(R.id.anim_text);
      
      AnimationSet anim = new AnimationSet(true);
TranslateAnimation mytranslateanim = new TranslateAnimation(Animation.RELATIVE_TO_SELF,0f,Animation.RELATIVE_TO_SELF,-1f,Animation.RELATIVE_TO_SELF,0f,Animation.RELATIVE_TO_SELF,0f);
mytranslateanim.setDuration(2000);
anim.setStartOffset(800);
anim.addAnimation(mytranslateanim);
anim.setFillAfter(true);
mLeft.startAnimation(anim);

AnimationSet anim1 = new AnimationSet(true);
TranslateAnimation mytranslateanim1 = new TranslateAnimation(Animation.RELATIVE_TO_SELF,0f,Animation.RELATIVE_TO_SELF,+1f,Animation.RELATIVE_TO_SELF,0f,Animation.RELATIVE_TO_SELF,0f);
mytranslateanim1.setDuration(1500);
anim1.addAnimation(mytranslateanim1);
anim1.setStartOffset(800);
anim1.setFillAfter(true);
mRight.startAnimation(anim1);

AnimationSet anim2 = new AnimationSet(true);
ScaleAnimation myscaleanim = new ScaleAnimation(1f,3f,1f,3f,Animation.RELATIVE_TO_SELF,0.5f,Animation.RELATIVE_TO_SELF,0.5f);
myscaleanim.setDuration(1000);
AlphaAnimation myalphaanim = new AlphaAnimation(1,0.0001f);
myalphaanim.setDuration(1500);
anim2.addAnimation(myscaleanim);
anim2.addAnimation(myalphaanim);
anim2.setFillAfter(true);
mText.startAnimation(anim2);
new Thread(this).start();
  }
 
Example 4
Project: ElAhorcado   File: MainActivity.java   View Source Code Vote up 6 votes
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    tvPulsa = (TextView) findViewById(R.id.tvPulsa);
    rl = (RelativeLayout) findViewById(R.id.activity_main);
    animation = AnimationUtils.loadAnimation(this, R.anim.fadeinout);

    tvPulsa.startAnimation(animation);

    rl.setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {

            Intent intent = new Intent(MainActivity.this, MenuActivity.class);
            startActivity(intent);

            return true;
        }
    });
}
 
Example 5
Project: Floo   File: WebActivity.java   View Source Code Vote up 6 votes
@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 6
Project: GitHub   File: ConsoleActivity.java   View Source Code Vote up 5 votes
@Override
public Object instantiateItem(ViewGroup container, int position) {
	if (bound == null || bound.getBridges().size() <= position) {
		Log.w(TAG, "Activity not bound when creating TerminalView.");
	}
	TerminalBridge bridge = bound.getBridges().get(position);
	bridge.promptHelper.setHandler(promptHandler);

	// inflate each terminal view
	RelativeLayout view = (RelativeLayout) inflater.inflate(
			R.layout.item_terminal, container, false);

	// set the terminal name overlay text
	TextView terminalNameOverlay = (TextView) view.findViewById(R.id.terminal_name_overlay);
	terminalNameOverlay.setText(bridge.host.getNickname());

	// and add our terminal view control, using index to place behind overlay
	final TerminalView terminal = new TerminalView(container.getContext(), bridge, pager);
	terminal.setId(R.id.terminal_view);
	view.addView(terminal, 0);

	// Tag the view with its bridge so it can be retrieved later.
	view.setTag(bridge);

	container.addView(view);
	terminalNameOverlay.startAnimation(fade_out_delayed);
	return view;
}
 
Example 7
Project: labtablet   File: FormSolverActivity.java   View Source Code Vote up 5 votes
@Override
public void onClick(View view) {

    //Extract values from children
    LinearLayout rowsView = (LinearLayout) rootView.findViewById(R.id.repeatable_items);

    ArrayList<String> row = new ArrayList<>();
    for (int i = 0; i < rowsView.getChildCount(); ++i) {
        EditText et = (EditText) rowsView.getChildAt(i).findViewById(R.id.input_row);
        row.add(et.getText().toString());
    }
    fq.addRow(row);
    TextView tvCount = (TextView) rootView.findViewById(R.id.question_items_count);

    tvCount.setText(fq.getRows().size() + " items");
    Toast.makeText(FormSolverActivity.this, "SAVED", Toast.LENGTH_SHORT).show();

    Animation animation = new ScaleAnimation(1,1.1f,1,1.1f);
    animation.setDuration(300);
    animation.setRepeatMode(Animation.REVERSE);
    animation.setRepeatCount(1);
    tvCount.startAnimation(animation);

    //Remove any child from view
    ((LinearLayout) rootView.findViewById(R.id.repeatable_items)).removeAllViews();
    ((Button) rootView.findViewById(R.id.question_add_response_instance)).setText(getString(R.string.action_new_row));
    rootView.findViewById(R.id.question_add_response_instance).setOnClickListener(new onRowAddedListener(rootView, fq));
    fab.show();
}
 
Example 8
Project: SwolyV2   File: MaxesAdapter.java   View Source Code Vote up 5 votes
protected void percentageClick(Button button,TextView title,
                               TextView currMax, View v){
    final Animation percentAnimation = AnimationUtils.loadAnimation
            (currMax.getContext(), android.R.anim.fade_in);
    String liftName = MaxesFragment.createValidString(title.getText().toString()
            .toLowerCase().trim());
    DBHandler db = new DBHandler(v.getContext(), liftName);
    float newWeight, oldWeight = findLastValue(db, liftName);
    float percentage = Float.parseFloat(button.getText().toString())/100;
    newWeight = Math.round((((oldWeight*percentage)-45)/2));
    currMax.startAnimation(percentAnimation);
    currMax.setText(String.valueOf(newWeight));
    db.close();
}
 
Example 9
Project: buildAPKsApps   File: BloodType.java   View Source Code Vote up 5 votes
@Override
protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	setContentView(R.layout.bloodtype);
	
	prefs = this.getSharedPreferences("BloodType", Context.MODE_PRIVATE);
	
	strAndroidInfo = prefs.getString("BloodVal", "");
	inPrefConv = Integer.parseInt(strAndroidInfo);
	
	tvG = (TextView) findViewById(R.id.tvGiveTo);
	tvR = (TextView) findViewById(R.id.tvReceiveFrom);
	
	tvB = (TextView) findViewById(R.id.tvBloodDetail);
	tvB.setText(strBloodType[inPrefConv]);
	
	tvD = (TextView) findViewById(R.id.tvData);
	tvD.setTypeface(Typeface.createFromAsset(BloodType.this.getAssets(), "fonts/gbold.otf"));
	
	tvA = (TextView) findViewById(R.id.tvGive);
	tvC = (TextView) findViewById(R.id.tvReceive);
	
	animAnticipateOvershoot = AnimationUtils.loadAnimation(this, R.anim.overshoot);
	tvB.startAnimation(animAnticipateOvershoot);
	animAnticipateOvershootX = AnimationUtils.loadAnimation(this, R.anim.overshootx);
	tvC.startAnimation(animAnticipateOvershootX);
	tvA.startAnimation(animAnticipateOvershootX);
	
	//Handler handler = new Handler();
       //handler.postDelayed(task, 1000);
	
	PerformBloodCheck(inPrefConv);
	
	getActionBar().setDisplayHomeAsUpEnabled(true);
}
 
Example 10
Project: Sistema-de-Comercializacion-Negocios-Jhordan   File: Splash.java   View Source Code Vote up 5 votes
@Override
protected void onCreate(Bundle savedInstanceState) {
    this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
    super.onCreate(savedInstanceState);
    setContentView(R.layout.splash);

    tv = (TextView) findViewById(R.id.tv);
    iv = (ImageView) findViewById(R.id.iv);


    Animation myanim = AnimationUtils.loadAnimation(this, R.anim.mytrasition);
    tv.startAnimation(myanim);
    iv.startAnimation(myanim);
    final Intent i = new Intent(this, Activity_login.class);
    Thread timer = new Thread(){
        public void run(){
            try{
                sleep(5000);}
            catch (Exception e){
                System.out.println(e.getMessage());
                e.printStackTrace();
            }finally {
                startActivity(i);
                finish();
            }
        }
    };
          timer.start();
}
 
Example 11
Project: JUMBLE-WORD-GAME   File: ScoreActivity.java   View Source Code Vote up 5 votes
protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	setContentView(R.layout.activity_score);
	
	tv=(TextView) findViewById(R.id.textView2);
	v=(TextView) findViewById(R.id.textView3);
	vt=(TextView) findViewById(R.id.textView1);
	Intent i=getIntent();
	int score=i.getIntExtra("s", 0);
	String result=i.getStringExtra("result");
	tv.setText("Score = "+score);
	v.setText(result);
	v.startAnimation((Animation)AnimationUtils.loadAnimation(this, R.anim.translate));
	
}
 
Example 12
Project: FreeStreams-TVLauncher   File: AppFragment.java   View Source Code Vote up 5 votes
@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
Project: AnimatedPullToRefresh-master   File: AnimationHelper.java   View Source Code Vote up 4 votes
/**
 * 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 14
Project: Gif-Load-ReTry-Refresh   File: LoadReTryRefreshManager.java   View Source Code Vote up 4 votes
private void initLoadView(Activity activity) {
    View loadView=hashMap_activity_loadView.get(activity);
    LinearLayout loadretry_parent=(LinearLayout)loadView.findViewById(R.id.loadretry_parent);
    GifImageView gifImageView=(GifImageView)loadView.findViewById(R.id.loadretry_gifview);
    TextView tv_error=(TextView)loadView.findViewById(R.id.loadretry_tv_error);
    AlphaAnimation alphaAnimation = new AlphaAnimation(0,1);
    alphaAnimation.setDuration(loadRetryRefreshConfig.getStartAnimTime());
    gifImageView.startAnimation(alphaAnimation);
    tv_error.startAnimation(alphaAnimation);
    gifImageView.setVisibility(View.VISIBLE);
    tv_error.setVisibility(View.VISIBLE);
    RTextView tv_retry=(RTextView)loadView.findViewById(R.id.loadretry_tv_retry);
    tv_retry.setVisibility(View.INVISIBLE);
    if (loadRetryRefreshConfig !=null){
        if (loadRetryRefreshConfig.getGif()!=0){
            setGifImageView(activity,gifImageView,false);
        }
        if (loadRetryRefreshConfig.getBackgroundColor()!=0){
            loadretry_parent.setBackgroundColor(activity.getResources().getColor(loadRetryRefreshConfig.getBackgroundColor()));
        }
        if (loadRetryRefreshConfig.getBtnBorderColor()!=0){
            tv_retry.setBorderColorNormal(activity.getResources().getColor(loadRetryRefreshConfig.getBtnBorderColor()));
            tv_retry.setBorderColorPressed(activity.getResources().getColor(loadRetryRefreshConfig.getBtnBorderColor()));
            tv_retry.setBorderWidthNormal(dip2px(activity,1));
            tv_retry.setBorderWidthPressed(dip2px(activity,1));
        }
        if (loadRetryRefreshConfig.getBtnNormalColor()!=0&& loadRetryRefreshConfig.getBtnPressedColor()!=0){
            tv_retry.setBackgroundColorNormal(activity.getResources().getColor(loadRetryRefreshConfig.getBtnNormalColor()));
            tv_retry.setBackgroundColorPressed(activity.getResources().getColor(loadRetryRefreshConfig.getBtnPressedColor()));
        }
        if (loadRetryRefreshConfig.getBtnRadius()!=null){
            tv_retry.setCornerRadius(loadRetryRefreshConfig.getBtnRadius());
        }
        if (loadRetryRefreshConfig.getBtnTextColor()!=0){
            tv_retry.setTextColor(activity.getResources().getColor(loadRetryRefreshConfig.getBtnTextColor()));
        }
        if (!TextUtils.isEmpty(loadRetryRefreshConfig.getBtnText())){
            tv_retry.setText(loadRetryRefreshConfig.getBtnText());
        }
        if (loadRetryRefreshConfig.getLoadAndErrorTextColor()!=0){
            tv_error.setTextColor(activity.getResources().getColor(loadRetryRefreshConfig.getLoadAndErrorTextColor()));
        }
        if (!TextUtils.isEmpty(loadRetryRefreshConfig.getLoadText())){
            tv_error.setText(loadRetryRefreshConfig.getLoadText());
        }
    }
}
 
Example 15
Project: Gif-Load-ReTry-Refresh   File: LoadReTryRefreshManager.java   View Source Code Vote up 4 votes
private void initLoadView(Fragment fragment) {
    View loadView=hashMap_fragment_loadView.get(fragment);
    LinearLayout loadretry_parent=(LinearLayout)loadView.findViewById(R.id.loadretry_parent);
    GifImageView gifImageView=(GifImageView)loadView.findViewById(R.id.loadretry_gifview);
    TextView tv_error=(TextView)loadView.findViewById(R.id.loadretry_tv_error);
    RTextView tv_retry=(RTextView)loadView.findViewById(R.id.loadretry_tv_retry);
    AlphaAnimation alphaAnimation = new AlphaAnimation(0,1);
    alphaAnimation.setDuration(loadRetryRefreshConfig.getStartAnimTime());
    gifImageView.startAnimation(alphaAnimation);
    tv_error.startAnimation(alphaAnimation);
    gifImageView.setVisibility(View.VISIBLE);
    tv_error.setVisibility(View.VISIBLE);
    tv_retry.setVisibility(View.INVISIBLE);
    if (loadRetryRefreshConfig !=null){
        if (loadRetryRefreshConfig.getGif()!=0){
            setGifImageView(fragment.getActivity(),gifImageView,false);
        }
        if (loadRetryRefreshConfig.getBackgroundColor()!=0){
            loadretry_parent.setBackgroundColor(fragment.getActivity().getResources().getColor(loadRetryRefreshConfig.getBackgroundColor()));
        }
        if (loadRetryRefreshConfig.getBtnBorderColor()!=0){
            tv_retry.setBorderColorNormal(fragment.getActivity().getResources().getColor(loadRetryRefreshConfig.getBtnBorderColor()));
            tv_retry.setBorderColorPressed(fragment.getActivity().getResources().getColor(loadRetryRefreshConfig.getBtnBorderColor()));
            tv_retry.setBorderWidthNormal(dip2px(fragment.getActivity(),1));
            tv_retry.setBorderWidthPressed(dip2px(fragment.getActivity(),1));
        }
        if (loadRetryRefreshConfig.getBtnNormalColor()!=0&& loadRetryRefreshConfig.getBtnPressedColor()!=0){
            tv_retry.setBackgroundColorNormal(fragment.getActivity().getResources().getColor(loadRetryRefreshConfig.getBtnNormalColor()));
            tv_retry.setBackgroundColorPressed(fragment.getActivity().getResources().getColor(loadRetryRefreshConfig.getBtnPressedColor()));
        }
        if (loadRetryRefreshConfig.getBtnRadius()!=null){
            tv_retry.setCornerRadius(loadRetryRefreshConfig.getBtnRadius());
        }
        if (loadRetryRefreshConfig.getBtnTextColor()!=0){
            tv_retry.setTextColor(fragment.getActivity().getResources().getColor(loadRetryRefreshConfig.getBtnTextColor()));
        }
        if (!TextUtils.isEmpty(loadRetryRefreshConfig.getBtnText())){
            tv_retry.setText(loadRetryRefreshConfig.getBtnText());
        }
        if (loadRetryRefreshConfig.getLoadAndErrorTextColor()!=0){
            tv_error.setTextColor(fragment.getActivity().getResources().getColor(loadRetryRefreshConfig.getLoadAndErrorTextColor()));
        }
        if (!TextUtils.isEmpty(loadRetryRefreshConfig.getLoadText())){
            tv_error.setText(loadRetryRefreshConfig.getLoadText());
        }
    }
}
 
Example 16
Project: PhotoPickApp   File: AnimationUtil.java   View Source Code Vote up 4 votes
public static void startAnimation(Activity activity, int selectNum, View startView, View endView) {
    TextView textView = new TextView(activity);
    ViewGroup decorView = (ViewGroup) activity.getWindow().getDecorView();
    LinearLayout animLayout = new LinearLayout(activity);
    LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(
            LinearLayout.LayoutParams.MATCH_PARENT,
            LinearLayout.LayoutParams.MATCH_PARENT);
    animLayout.setLayoutParams(lp);
    animLayout.setBackgroundResource(android.R.color.transparent);
    decorView.addView(animLayout);
    textView.setTextColor(Color.WHITE);
    textView.setText(String.valueOf(selectNum));
    textView.setBackground(ContextCompat.getDrawable(activity, R.drawable.image_select));
    textView.setGravity(Gravity.CENTER);
    animLayout.addView(textView);

    int[] locs = new int[2];
    endView.getLocationInWindow(locs);
    int[] loc2 = new int[2];
    startView.getLocationInWindow(loc2);

    LinearLayout.LayoutParams textParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    textParams.leftMargin = loc2[0];
    textParams.topMargin = loc2[1];
    textView.setLayoutParams(textParams);


    Animation topTranslateAnimation = new TranslateAnimation(0, (locs[0] - loc2[0]) / 3, 0, (locs[1] - loc2[1]) / 3);
    topTranslateAnimation.setDuration(1000);
    topTranslateAnimation.setInterpolator(activity, android.R.anim.linear_interpolator);
    topTranslateAnimation.setFillAfter(false);

    Animation alphaAnimation = new AlphaAnimation(1, 0);
    alphaAnimation.setDuration(1000);

    AnimationSet animationSet = new AnimationSet(false);
    animationSet.addAnimation(topTranslateAnimation);
    animationSet.addAnimation(alphaAnimation);
    animationSet.setFillAfter(true);
    textView.startAnimation(animationSet);
}
 
Example 17
Project: cryptotracker   File: SplashScreenActivity.java   View Source Code Vote up 4 votes
private void animation() {
    TextView textView = (TextView) findViewById(R.id.zysit_text_logo);
    textView.setAlpha(1.0F);
    Animation localAnimation = AnimationUtils.loadAnimation(this, R.anim.translate_top_to_center);
    textView.startAnimation(localAnimation);
}
 
Example 18
Project: android_ui   File: EditLayout.java   View Source Code Vote up 3 votes
/**
 * Invoked whenever a change in the text within EditText occurs and hint view should be showed or
 * hided by animation.
 * <p>
 * This implementation uses animations provided by {@link R.attr#uiFloatingLabelAnimationIn}
 * and {@link R.attr#uiFloatingLabelAnimationOut} obtained from the style set to this view
 * or from Xml layout file.
 *
 * @param labelView Label text view to be animated. If showing, this text view already contains
 *                  the current hint from EditText.
 * @param show      {@code True} if label view should be showed, {@code false} to be hided.
 * @return {@code True} if label view was showed/hided by animation, {@code false} if it should
 * be showed/hided just by changing its visibility flag.
 */
protected boolean onAnimateLabel(@NonNull TextView labelView, boolean show) {
	if (show && mLabelInAnimation != null) {
		labelView.setVisibility(View.VISIBLE);
		labelView.startAnimation(mLabelInAnimation);
		return true;
	}
	if (!show && mLabelOutAnimation != null) {
		labelView.startAnimation(mLabelOutAnimation);
		return true;
	}
	return false;
}