Example usage for android.view View animate

List of usage examples for android.view View animate

Introduction

In this page you can find the example usage for android.view View animate.

Prototype

public ViewPropertyAnimator animate() 

Source Link

Document

This method returns a ViewPropertyAnimator object, which can be used to animate specific properties on this View.

Usage

From source file:uk.ac.horizon.artcodes.ui.MarkerHistoryViewController.java

private void animateRemoval(final View view) {
    view.animate().setListener(new Animator.AnimatorListener() {
        @Override//from w  w  w .ja v  a  2  s.c  om
        public void onAnimationStart(Animator animator) {

        }

        @Override
        public void onAnimationEnd(Animator animator) {
            relativeLayout.removeView(view);
        }

        @Override
        public void onAnimationCancel(Animator animator) {

        }

        @Override
        public void onAnimationRepeat(Animator animator) {

        }
    }).alpha(0).setInterpolator(new LinearInterpolator()).setDuration(ANIMATION_DURATION_MS).start();
}

From source file:uk.ac.horizon.artcodes.ui.MarkerHistoryViewController.java

private void animateEnterOrMove(View view, int x, int y, float scale) {
    view.animate().alpha(1).translationX(x).translationY(y).scaleX(scale).scaleY(scale)
            .setDuration(ANIMATION_DURATION_MS).setInterpolator(new LinearInterpolator()).start();
}

From source file:task.application.com.colette.navigation.AppNavigationViewAsDrawerImpl.java

private void onNavDrawerItemClicked(final NavigationModel.NavigationItemEnum item) {
    if (item == mSelfItem) {
        mDrawerLayout.closeDrawer(GravityCompat.START);
        setSelectedNavDrawerItem(item);/*from  w ww . j av a 2 s .  co m*/
        return;
    }

    if (isSpecialItem(item)) {
        itemSelected(item);
    } else {
        // Launch the target Activity after a short delay, to allow the close animation to play
        mHandler.postDelayed(() -> itemSelected(item), NAVDRAWER_LAUNCH_DELAY);

        // Change the active item on the list so the user can see the item changed
        setSelectedNavDrawerItem(item);
        // Fade out the main content
        View mainContent = mActivity.findViewById(R.id.main_content);
        if (mainContent != null) {
            mainContent.animate().alpha(0).setDuration(MAIN_CONTENT_FADEOUT_DURATION);
            //                mainContent.animate().alpha(1).setDuration(250);
        }
    }

    // The navigation menu is accessible from some screens, via swiping, without a drawer
    // layout, eg MapActivity when accessed from SessionDetailsActivity.
    if (mDrawerLayout != null) {
        mDrawerLayout.closeDrawer(GravityCompat.START);
    }
}

From source file:com.eggwall.SoundSleep.SleepActivity.java

/**
 * Sets the visibility of the icons back to full brightness.
 *///from   w w w. j  ava  2 s .c om
void resetAlphaDecrement() {
    if (SDK < 11) {
        return;
    }
    mAlphaDecrement = 0;
    final View cloud = findViewById(R.id.cloud);
    final View note = findViewById(R.id.note);
    cloud.animate().alpha((float) .35);
    note.animate().alpha((float) .50);
}

From source file:com.jun.elephant.ui.user.info.UserInfoActivity.java

private void alphaView(View view, long duration, int i) {
    view.animate().alpha(i == 0 ? 1.0f : 0.0f).setDuration(duration).start();
}

From source file:org.secuso.privacyfriendlynetmonitor.Activities.BaseActivity.java

public void setToolbar() {
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    if (getSupportActionBar() == null) {
        setSupportActionBar(toolbar);//  ww  w  .  jav a2s .  c  o m
    }

    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, mDrawerLayout, toolbar,
            R.string.navigation_drawer_open, R.string.navigation_drawer_close);
    mDrawerLayout.addDrawerListener(toggle);
    toggle.syncState();

    mNavigationView = (NavigationView) findViewById(R.id.nav_view);
    mNavigationView.setNavigationItemSelectedListener(this);

    selectNavigationItem(getNavigationDrawerID());

    View mainContent = findViewById(R.id.main_content);
    if (mainContent != null) {
        mainContent.setAlpha(0);
        mainContent.animate().alpha(1).setDuration(MAIN_CONTENT_FADEIN_DURATION);
    }
}

From source file:com.google.samples.apps.iosched.ui.SearchActivity.java

/**
 * On Lollipop+ perform a circular reveal animation (an expanding circular mask) when showing
 * the search panel./*from www.  ja  v  a  2 s.co  m*/
 */
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private void doEnterAnim() {
    // Fade in a background scrim as this is a floating window. We could have used a
    // translucent window background but this approach allows us to turn off window animation &
    // overlap the fade with the reveal animation  making it feel snappier.
    View scrim = findViewById(R.id.scrim);
    scrim.animate().alpha(1f).setDuration(500L)
            .setInterpolator(AnimationUtils.loadInterpolator(this, android.R.interpolator.fast_out_slow_in))
            .start();

    // Next perform the circular reveal on the search panel
    final View searchPanel = findViewById(R.id.search_panel);
    if (searchPanel != null) {
        // We use a view tree observer to set this up once the view is measured & laid out
        searchPanel.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {
            @Override
            public boolean onPreDraw() {
                searchPanel.getViewTreeObserver().removeOnPreDrawListener(this);
                // As the height will change once the initial suggestions are delivered by the
                // loader, we can't use the search panels height to calculate the final radius
                // so we fall back to it's parent to be safe
                int revealRadius = ((ViewGroup) searchPanel.getParent()).getHeight();
                // Center the animation on the top right of the panel i.e. near to the
                // search button which launched this screen.
                Animator show = ViewAnimationUtils.createCircularReveal(searchPanel, searchPanel.getRight(),
                        searchPanel.getTop(), 0f, revealRadius);
                show.setDuration(250L);
                show.setInterpolator(AnimationUtils.loadInterpolator(SearchActivity.this,
                        android.R.interpolator.fast_out_slow_in));
                show.start();
                return false;
            }
        });
    }
}

From source file:systems.soapbox.ombuds.client.ui.omb.SearchActivity.java

/**
 * On Lollipop+ perform a circular reveal animation (an expanding circular mask) when showing
 * the search panel./*from   w w  w.  ja  v a  2s  .  co m*/
 *
 * Support CircularReveal :
 * https://github.com/ozodrukh/CircularReveal
 */
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private void doEnterAnim() {
    // Fade in a background scrim as this is a floating window. We could have used a
    // translucent window background but this approach allows us to turn off window animation &
    // overlap the fade with the reveal animation  making it feel snappier.
    View scrim = findViewById(R.id.scrim);
    scrim.animate().alpha(1f).setDuration(500L)
            .setInterpolator(AnimationUtils.loadInterpolator(this, android.R.interpolator.fast_out_slow_in))
            .start();

    // Next perform the circular reveal on the search panel
    final View searchPanel = findViewById(R.id.search_panel);
    if (searchPanel != null) {
        // We use a view tree observer to set this up once the view is measured & laid out
        searchPanel.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {
            @Override
            public boolean onPreDraw() {
                searchPanel.getViewTreeObserver().removeOnPreDrawListener(this);
                // As the height will change once the initial suggestions are delivered by the
                // loader, we can't use the search panels height to calculate the final radius
                // so we fall back to it's parent to be safe
                int revealRadius = ((ViewGroup) searchPanel.getParent()).getHeight();
                // Center the animation on the top right of the panel i.e. near to the
                // search button which launched this screen.
                Animator show = ViewAnimationUtils.createCircularReveal(searchPanel, searchPanel.getRight(),
                        searchPanel.getTop(), 0f, revealRadius);
                show.setDuration(350L);
                show.setInterpolator(AnimationUtils.loadInterpolator(SearchActivity.this,
                        android.R.interpolator.fast_out_slow_in));
                show.start();
                return false;
            }
        });
    }
}

From source file:com.osama.cgpacalculator.MainActivity.java

private void gpaAnimation(View view) {
    ScaleAnimation animation = new ScaleAnimation(0f, 1f, 1f, 1f);
    animation.setDuration(500);/*from   w w w. jav a2  s .  com*/
    view.setAnimation(animation);
    view.animate();
}

From source file:com.amaze.filemanager.utils.files.FileUtils.java

public static void crossfadeInverse(final View buttons, final View pathbar) {
    // Set the content view to 0% opacity but visible, so that it is visible
    // (but fully transparent) during the animation.

    pathbar.setAlpha(0f);/*from   www  .  j a  v a 2  s .co  m*/
    pathbar.setVisibility(View.VISIBLE);

    // Animate the content view to 100% opacity, and clear any animation
    // listener set on the view.
    pathbar.animate().alpha(1f).setDuration(500).setListener(null);
    buttons.animate().alpha(0f).setDuration(500).setListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            buttons.setVisibility(View.GONE);
        }
    });
    // Animate the loading view to 0% opacity. After the animation ends,
    // set its visibility to GONE as an optimization step (it won't
    // participate in layout passes, etc.)
}