Example usage for android.view.animation Animation setFillAfter

List of usage examples for android.view.animation Animation setFillAfter

Introduction

In this page you can find the example usage for android.view.animation Animation setFillAfter.

Prototype

public void setFillAfter(boolean fillAfter) 

Source Link

Document

If fillAfter is true, the transformation that this animation performed will persist when it is finished.

Usage

From source file:com.breadwallet.tools.animation.BRAnimator.java

public static void scaleView(View v, float startScaleX, float endScaleX, float startScaleY, float endScaleY) {
    Animation anim = new ScaleAnimation(startScaleX, endScaleX, // Start and end values for the X axis scaling
            startScaleY, endScaleY, // Start and end values for the Y axis scaling
            Animation.RELATIVE_TO_SELF, 0.5f, // Pivot point of X scaling
            Animation.RELATIVE_TO_SELF, 0.5f); // Pivot point of Y scaling
    anim.setFillAfter(true); // Needed to keep the result of the animation
    v.startAnimation(anim);/*from   w  w w  . j a  va 2 s .c  om*/
}

From source file:com.flan.stock.view.TouTiaoPagerView.java

/**
 * ? ?/* w ww .  j  a  va2s  .c o m*/
 * @param position
 */
private void setCurrentTab(int position) {

    Animation animation = null;
    animation = new TranslateAnimation(tabImgWidth * currentTab, tabImgWidth * position, 0, 0);
    animation.setFillAfter(true);//True:???
    animation.setDuration(300); //?
    img_tab.startAnimation(animation);

    currentTab = position;
}

From source file:com.gigamole.millspinners.lib.CirclesWaveSpinner.java

private void init() {
    final LayoutParams tempArcViewLayoutParams = new LayoutParams(this.diameter, this.diameter);
    tempArcViewLayoutParams.gravity = Gravity.CENTER;

    for (int i = 0; i < this.circleViews.length; i++) {
        final CircleView tempCircleView = new CircleView(getContext());
        tempCircleView.setColor(this.colors[colorCounter++]);
        if (this.colorCounter == 3) {
            this.colorCounter = 0;
        }/*from  w  ww  .j  a va2 s .  c  om*/

        tempCircleView.setStartOffset((this.circleViews.length - 1 - i) * this.startOffset);
        tempCircleView.setStrokeWidth(this.strokeWidth);
        tempCircleView.setCircleMargin(this.marginCircleCounter += this.marginCircle);

        tempCircleView.setLayoutParams(tempArcViewLayoutParams);

        this.circleViews[i] = tempCircleView;
    }

    for (int i = this.circleViews.length - 1; i >= 0; i--) {
        this.addView(this.circleViews[i]);
        this.circleViews[i].init();
    }

    final Animation animation = new RotateAnimation(0, -45, this.radius, this.radius);
    animation.setFillAfter(true);
    startAnimation(animation);
}

From source file:com.flan.stock.view.NewsTabView.java

/**
 * ? ?//from  w w  w. jav a2 s  .  com
 * @param position
 */
public void setCurrentTab(int position) {

    tv_tag1.setTextSize(14);
    tv_tag2.setTextSize(14);
    tv_tag3.setTextSize(14);
    tv_tag4.setTextSize(14);
    tv_tag5.setTextSize(14);

    switch (position) {
    case 0:
        tv_tag1.setTextSize(16);
        break;
    case 1:
        tv_tag2.setTextSize(16);
        break;
    case 2:
        tv_tag3.setTextSize(16);
        break;
    case 3:
        tv_tag4.setTextSize(16);
        break;
    case 4:
        tv_tag5.setTextSize(16);
        break;
    }

    Animation animation = null;
    animation = new TranslateAnimation(imgWidth * currentTab, imgWidth * position, 0, 0);
    animation.setFillAfter(true);//True:???
    animation.setDuration(300); //?
    img_cursor.startAnimation(animation);

    currentTab = position;

}

From source file:com.pepperonas.andbasx.animation.FadeAnimationColored.java

/**
 * Fade in.//from   w w  w  . j a va  2s .  c  o  m
 */
public void fadeIn() {
    Animation anim = new AlphaAnimation(maxBrightness, minBrightness);
    anim.setDuration(duration);
    anim.setStartOffset(startOffset);
    anim.setFillEnabled(true);
    anim.setFillAfter(true);
    view.startAnimation(anim);
}

From source file:com.flan.stock.view.AnimationTabWidget.java

/**
 * ? ?/*  w w  w  .  ja va  2s .c  o  m*/
 * @param position
 */
public void setCurrentTab(int position) {

    tv_tag1.setTextSize(12);
    tv_tag2.setTextSize(12);
    tv_tag3.setTextSize(12);
    tv_tag4.setTextSize(12);
    tv_tag5.setTextSize(12);

    tv_tag1.setTextColor(whiteColor);
    tv_tag2.setTextColor(whiteColor);
    tv_tag3.setTextColor(whiteColor);
    tv_tag4.setTextColor(whiteColor);
    tv_tag5.setTextColor(whiteColor);

    switch (position) {
    case 0:
        tv_tag1.setTextColor(redColor);
        tv_tag1.setTextSize(16);
        break;
    case 1:
        tv_tag2.setTextColor(redColor);
        tv_tag2.setTextSize(16);
        break;
    case 2:
        tv_tag3.setTextColor(redColor);
        tv_tag3.setTextSize(16);
        break;
    case 3:
        tv_tag4.setTextColor(redColor);
        tv_tag4.setTextSize(16);
        break;
    case 4:
        tv_tag5.setTextColor(redColor);
        tv_tag5.setTextSize(16);
        break;
    }

    Animation animation = null;
    animation = new TranslateAnimation(imgWidth * currentTab, imgWidth * position, 0, 0);
    animation.setFillAfter(true);//True:???
    animation.setDuration(300); //?
    img_cursor.startAnimation(animation);

    currentTab = position;

}

From source file:com.pepperonas.andbasx.animation.FadeAnimationColored.java

/**
 * Fade out./*from   ww  w  .  j a v a 2 s . c  om*/
 */
public void fadeOut() {
    this.view.setAlpha(1f);
    Animation anim = new AlphaAnimation(minBrightness, maxBrightness);
    anim.setDuration(duration);
    anim.setStartOffset(startOffset);
    anim.setFillEnabled(true);
    anim.setFillAfter(true);
    view.startAnimation(anim);
}

From source file:com.example.demo_highlights.slidingmenu.fragment.PageFragment1.java

private LayoutAnimationController getListAnim() {
    AnimationSet set = new AnimationSet(true);
    Animation animation = new AlphaAnimation(0.0f, 1.0f);
    animation.setDuration(200);//from  w  ww. ja va2s  .  c  o  m
    set.addAnimation(animation);

    animation = 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);
    animation.setDuration(200);
    set.addAnimation(animation);

    Animation inAnimation = new TranslateAnimation(Animation.RELATIVE_TO_SELF, -1.0f,
            Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF,
            0.0f);
    inAnimation.setDuration(200);
    inAnimation.setFillAfter(true);
    set.addAnimation(inAnimation);

    Animation outAnimation = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0.0f,
            Animation.RELATIVE_TO_SELF, 1.0f, Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF,
            0.0f);
    outAnimation.setDuration(200);
    outAnimation.setFillAfter(true);
    // 
    LayoutAnimationController inController = new LayoutAnimationController(inAnimation, 0.3f);
    // 
    LayoutAnimationController outController = new LayoutAnimationController(outAnimation, 0.3f);

    LayoutAnimationController controller = new LayoutAnimationController(set, 0.5f);
    return controller;
}

From source file:quickbeer.android.next.activities.base.SearchBarActivity.java

private void setupSearch() {
    adapter = new SearchAdapter(this, getInitialQueriesObservable(), getQueryObservable());
    searchViewOverlay = findViewById(R.id.search_view_overlay);
    searchViewOverlay.setOnTouchListener((view, event) -> {
        if (event.getAction() == MotionEvent.ACTION_UP && searchView.isSearchOpen()) {
            searchView.closeSearch();//from w  w w.  ja va  2 s  .com
        }
        return true;
    });

    searchView = (MaterialSearchView) findViewById(R.id.search_view);
    searchView.setHint(getSearchHint());
    searchView.setOnQueryTextListener(new MaterialSearchView.OnQueryTextListener() {
        @Override
        public boolean onQueryTextSubmit(String query) {
            Log.d(TAG, "onQueryTextSubmit(" + query + ")");
            if (updateQueryText(query)) {
                searchView.closeSearch();
            }
            return true;
        }

        @Override
        public boolean onQueryTextChange(String query) {
            Log.v(TAG, "onQueryTextChange(" + query + ")");
            if (liveFilteringEnabled()) {
                updateQueryText(query);
            }
            return true;
        }

        private boolean updateQueryText(String query) {
            if (query.length() > minimumSearchLength()) {
                querySubject.onNext(query);
                return true;
            } else {
                showTooShortSearchError();
                return false;
            }
        }
    });

    searchView.setOnSearchViewListener(new MaterialSearchView.SearchViewListener() {
        @Override
        public void onSearchViewAboutToClose() {
        }

        @Override
        public void onSearchViewAboutToShow() {
            Log.d(TAG, "onSearchViewAboutToShow");

            // TODO better subscription handling
            activitySubscription
                    .add(getQueryObservable().first().subscribe(query -> searchView.setQuery(query, false)));

            if (contentOverlayEnabled()) {
                Animation fadeIn = new AlphaAnimation(0.0f, 0.5f);
                fadeIn.setDuration(AnimationUtil.ANIMATION_DURATION_MEDIUM);
                fadeIn.setFillAfter(true);

                searchViewOverlay.setVisibility(View.VISIBLE);
                searchViewOverlay.startAnimation(fadeIn);
            }
        }

        @Override
        public void onSearchViewShown() {
            Log.d(TAG, "onSearchViewShown");

            searchView.setAdapter(adapter);
        }

        @Override
        public void onSearchViewClosed() {
            Log.d(TAG, "onSearchViewClosed");

            searchView.setAdapter(null);
            searchViewOverlay.clearAnimation();
            searchViewOverlay.setVisibility(View.GONE);
        }
    });

    searchView.setOnItemClickListener((parent, view, position, id) -> {
        searchView.closeSearch();
        querySubject.onNext(adapter.getItem(position));
    });
}

From source file:com.skubit.comics.activities.ComicViewerActivity.java

@Override
public void toggleView() {
    if (mIsFullView) {
        toolbar.setVisibility(View.VISIBLE);
        toolbar.animate().translationY(0);

        mMainView.setBackgroundColor(getResources().getColor(android.R.color.background_light));
        mIsFullView = false;//from  w w  w . j  a  v  a  2 s. c o m

        mSlider.setVisibility(View.VISIBLE);
        mSlider.animate().translationY(0);
        mSlider.setValue(mPager.getCurrentItem());

        final Animation anim = AnimationUtils.loadAnimation(this, R.anim.scale_in);
        anim.setFillEnabled(true);
        anim.setFillAfter(true);
        anim.setAnimationListener(new Animation.AnimationListener() {
            @Override
            public void onAnimationStart(Animation arg0) {
                mPager.setDrawingCacheEnabled(true);
            }

            @Override
            public void onAnimationRepeat(Animation arg0) {
            }

            @Override
            public void onAnimationEnd(Animation arg0) {
                mPager.setScaleX(.83f);
                mPager.setScaleY(.83f);
                mPager.clearAnimation();
            }
        });

        mPager.setAnimation(anim);
        mPager.startAnimation(anim);

    } else {
        toolbar.animate().translationY(-toolbar.getHeight());
        toolbar.setLayoutAnimationListener(new Animation.AnimationListener() {
            @Override
            public void onAnimationStart(Animation animation) {

            }

            @Override
            public void onAnimationEnd(Animation animation) {
                toolbar.setVisibility(View.INVISIBLE);
            }

            @Override
            public void onAnimationRepeat(Animation animation) {

            }
        });

        mMainView.setBackgroundColor(getResources().getColor(android.R.color.background_dark));
        mIsFullView = true;

        mSlider.animate().translationY(mMainView.getHeight() + mSlider.getHeight());
        mSlider.setLayoutAnimationListener(new Animation.AnimationListener() {
            @Override
            public void onAnimationStart(Animation animation) {

            }

            @Override
            public void onAnimationEnd(Animation animation) {
                mSlider.setVisibility(View.INVISIBLE);
            }

            @Override
            public void onAnimationRepeat(Animation animation) {

            }
        });

        final Animation anim = AnimationUtils.loadAnimation(this, R.anim.scale_out);
        anim.setAnimationListener(new Animation.AnimationListener() {
            @Override
            public void onAnimationStart(Animation arg0) {
                mPager.setScaleX(1f);
                mPager.setScaleY(1f);
            }

            @Override
            public void onAnimationRepeat(Animation arg0) {
            }

            @Override
            public void onAnimationEnd(Animation arg0) {
                mPager.clearAnimation();
            }
        });
        mPager.setAnimation(anim);
        mPager.startAnimation(anim);

    }
}