List of usage examples for android.view View animate
public ViewPropertyAnimator animate()
From source file:com.rbware.github.androidcouchpotato.widget.AbstractMediaItemPresenter.java
/** * Each media item row can have multiple focusable elements; the details on the left and a set * of optional custom actions on the right. * The selector is a highlight that moves to highlight to cover whichever views is in focus. * * @param selectorView the selector view used to highlight an individual element within a row. * @param focusChangedView The component within the media row whose focus got changed. * @param layoutAnimator the ValueAnimator producing animation frames for the selector's width * and x-translation, generated by this method and stored for the each * {@link ViewHolder}. * @param isDetails Whether the changed-focused view is for a media item details (true) or * an action (false).// w w w .ja va 2 s .c om */ static ValueAnimator updateSelector(final View selectorView, View focusChangedView, ValueAnimator layoutAnimator, boolean isDetails) { int animationDuration = focusChangedView.getContext().getResources() .getInteger(android.R.integer.config_shortAnimTime); DecelerateInterpolator interpolator = new DecelerateInterpolator(); int layoutDirection = ViewCompat.getLayoutDirection(selectorView); if (!focusChangedView.hasFocus()) { // if neither of the details or action views are in focus (ie. another row is in focus), // animate the selector out. selectorView.animate().cancel(); selectorView.animate().alpha(0f).setDuration(animationDuration).setInterpolator(interpolator).start(); // keep existing layout animator return layoutAnimator; } else { // cancel existing layout animator if (layoutAnimator != null) { layoutAnimator.cancel(); layoutAnimator = null; } float currentAlpha = selectorView.getAlpha(); selectorView.animate().alpha(1f).setDuration(animationDuration).setInterpolator(interpolator).start(); final ViewGroup.MarginLayoutParams lp = (ViewGroup.MarginLayoutParams) selectorView.getLayoutParams(); ViewGroup rootView = (ViewGroup) selectorView.getParent(); sTempRect.set(0, 0, focusChangedView.getWidth(), focusChangedView.getHeight()); rootView.offsetDescendantRectToMyCoords(focusChangedView, sTempRect); if (isDetails) { if (layoutDirection == View.LAYOUT_DIRECTION_RTL) { sTempRect.right += rootView.getHeight(); sTempRect.left -= rootView.getHeight() / 2; } else { sTempRect.left -= rootView.getHeight(); sTempRect.right += rootView.getHeight() / 2; } } final int targetLeft = sTempRect.left; final int targetWidth = sTempRect.width(); final float deltaWidth = lp.width - targetWidth; final float deltaLeft = lp.leftMargin - targetLeft; if (deltaLeft == 0f && deltaWidth == 0f) { // no change needed } else if (currentAlpha == 0f) { // change selector to the proper width and marginLeft without animation. lp.width = targetWidth; lp.leftMargin = targetLeft; selectorView.requestLayout(); } else { // animate the selector to the proper width and marginLeft. layoutAnimator = ValueAnimator.ofFloat(0f, 1f); layoutAnimator.setDuration(animationDuration); layoutAnimator.setInterpolator(interpolator); layoutAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator valueAnimator) { // Set width to the proper width for this animation step. float fractionToEnd = 1f - valueAnimator.getAnimatedFraction(); lp.leftMargin = Math.round(targetLeft + deltaLeft * fractionToEnd); lp.width = Math.round(targetWidth + deltaWidth * fractionToEnd); selectorView.requestLayout(); } }); layoutAnimator.start(); } return layoutAnimator; } }
From source file:com.icenler.lib.view.LivingTabsLayout.java
private void animateToPendingTab(final int position, final int oldPosition) { final LivingTab newTab = tabs.get(position); final View newTv = newTab.textView; newTv.animate().setDuration(300).scaleY(1).scaleX(1).setListener(startListener).start(); final View newIv = newTab.iconView; newIv.animate().setDuration(300).scaleY(0).scaleX(0).start(); final LivingTab oldTab = tabs.get(oldPosition); final View oldTv = oldTab.textView; oldTv.animate().setDuration(300).scaleY(0).scaleX(0).start(); final View oldIv = oldTab.iconView; oldIv.animate().setDuration(300).scaleY(1).scaleX(1).setListener(stopListener).start(); }
From source file:com.unovo.apartment.ui.main.MainActivity.java
public void toggleNavTabView(boolean isShowOrHide) { final View view = mNavBar.getView(); if (view == null) return;/*from w w w . ja va 2 s . c om*/ // hide view.setVisibility(View.VISIBLE); if (!isShowOrHide) { view.animate().translationY(view.getHeight()).setDuration(180).setInterpolator(new LinearInterpolator()) .setListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { super.onAnimationEnd(animation); view.setTranslationY(view.getHeight()); view.setVisibility(View.GONE); } }); } else { view.animate().translationY(0).setDuration(180).setInterpolator(new LinearInterpolator()) .setListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { super.onAnimationEnd(animation); // fix:bug > ??? view.setVisibility(View.VISIBLE); view.setTranslationY(0); } }); } }
From source file:com.lcc.view.LivingTabsLayout.java
private void animateToPendingTab(final int position, final int oldPosition) { {/*from www.j av a 2s . co m*/ final LivingTab newTab = tabs.get(position); final View newTv = newTab.textView; newTv.animate().setDuration(300).scaleY(1).scaleX(1).setListener(startListener).start(); final View newIv = newTab.iconView; newIv.animate().setDuration(300).scaleY(0).scaleX(0).start(); final LivingTab oldTab = tabs.get(oldPosition); final View oldTv = oldTab.textView; oldTv.animate().setDuration(300).scaleY(0).scaleX(0).start(); final View oldIv = oldTab.iconView; oldIv.animate().setDuration(300).scaleY(1).scaleX(1).setListener(stopListener).start(); } }
From source file:com.zyq.uitoucheventtest.animator.CrossfadeActivity.java
/** * Cross-fades between {@link #mContentView} and {@link #mLoadingView}. *//*from w w w . j ava 2 s.c o m*/ private void showContentOrLoadingIndicator(boolean contentLoaded) { // Decide which view to hide and which to show. final View showView = contentLoaded ? mContentView : mLoadingView; final View hideView = contentLoaded ? mLoadingView : mContentView; showView.setAlpha(0f); showView.setVisibility(View.VISIBLE); showView.animate().alpha(1f).setDuration(mShortAnimationDuration).setListener(null); // Animate the "hide" 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.) hideView.animate().alpha(0f).setDuration(mShortAnimationDuration) .setListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { hideView.setVisibility(View.GONE); } }); }
From source file:uk.ac.horizon.artcodes.ui.MarkerHistoryViewController.java
private void animateEnterOrMove(View view, int x, int y) { view.animate().alpha(1).translationX(x).translationY(y).setDuration(ANIMATION_DURATION_MS) .setInterpolator(new LinearInterpolator()).start(); }
From source file:com.github.saiff35.livingtabs.LivingTabsLayout.java
private void animateToPendingTab(final int position, final int oldPosition) { {/*from ww w. j ava2 s . c o m*/ final LivingTab newTab = tabs.get(position); final View newTv = newTab.textView; newTv.animate().setDuration(300).scaleY(1).scaleX(1).setListener(startListener).start(); final View newIv = newTab.iconView; newIv.animate().setDuration(300).scaleY(0).scaleX(0).start(); final LivingTab oldTab = tabs.get(oldPosition); final View oldTv = oldTab.textView; oldTv.animate().setDuration(300).scaleY(0).scaleX(0).start(); final View oldIv = oldTab.iconView; oldIv.animate().setDuration(300).scaleY(1).scaleX(1).setListener(stopListener).start(); } }
From source file:org.secuso.privacyfriendlynetmonitor.Activities.BaseActivity.java
protected boolean goToNavigationItem(final int itemId) { if (itemId == getNavigationDrawerID()) { // just close drawer because we are already in this activity mDrawerLayout.closeDrawer(GravityCompat.START); return true; }/* www. j a v a2s .com*/ // delay transition so the drawer can close mHandler.postDelayed(new Runnable() { @Override public void run() { callDrawerItem(itemId); } }, NAVDRAWER_LAUNCH_DELAY); mDrawerLayout.closeDrawer(GravityCompat.START); selectNavigationItem(itemId); // fade out the active activity View mainContent = findViewById(R.id.main_content); if (mainContent != null) { mainContent.animate().alpha(0).setDuration(MAIN_CONTENT_FADEOUT_DURATION); } return true; }
From source file:org.secuso.privacyfriendlypasswordgenerator.activities.BaseActivity.java
@Override protected void onPostCreate(Bundle savedInstanceState) { super.onPostCreate(savedInstanceState); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); if (getSupportActionBar() == null) { setSupportActionBar(toolbar);/*from w w w . ja va2 s . co 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.personal.taskmanager2.utilities.RecyclerViewTouchListener.java
private void dismiss(final View view, final int position, boolean dismissRight) { view.animate().translationX(dismissRight ? mViewWidth : -mViewWidth).alpha(0).setDuration(mAnimationTime) .setListener(new AnimatorListenerAdapter() { @Override/* w ww .j av a2 s . c om*/ public void onAnimationEnd(Animator animation) { //performDismiss(view, position); } }); }