List of usage examples for android.widget TextView setAlpha
public void setAlpha(@FloatRange(from = 0.0, to = 1.0) float alpha)
From source file:com.eccyan.widget.SpinningTabStrip.java
private void selected(View tab) { TextView title = (TextView) tab.findViewById(R.id.tab_title); if (title != null) { title.setTypeface(tabTypeface, tabTypefaceSelectedStyle); title.setAlpha(tabTextSelectedAlpha); }/*from w ww . ja va 2 s. c om*/ }
From source file:kankan.wheel.widget.WheelView.java
/** * Draws items// w w w . java 2 s . c o m * @param canvas the canvas for drawing */ private void drawItems(Canvas canvas) { canvas.save(); int top = (currentItem - firstItem) * getItemHeight() + (getItemHeight() - getHeight()) / 2; canvas.translate(PADDING, -top + scrollingOffset); //?? AbstractWheelTextAdapter adapter = null; if (viewAdapter instanceof AbstractWheelTextAdapter) { adapter = (AbstractWheelTextAdapter) viewAdapter; } if (adapter != null && adapter.isEnableMultiTextColor()) { int targetIndex = -1; int minDis = Integer.MAX_VALUE; for (int i = 0; i < itemsLayout.getChildCount(); i++) { TextView child = (TextView) itemsLayout.getChildAt(i); int realTop = child.getTop() - top + scrollingOffset; int viewCenter = realTop + child.getHeight() / 2; Rect bounds = centerDrawable.getBounds(); int dis = Math.abs(viewCenter - bounds.centerY()); if (dis < minDis) { minDis = dis; targetIndex = i; } } for (int i = 0; i < itemsLayout.getChildCount(); i++) { TextView view = (TextView) itemsLayout.getChildAt(i); view.setAlpha(0.5f); view.setTextColor(adapter.getTextColor()); view.setTextSize(adapter.getTextSize()); adapter.setTextViewPadding(view, adapter.getTextPaddingTop(), adapter.getTextPaddingBottom()); } if (targetIndex != -1) { TextView view = (TextView) itemsLayout.getChildAt(targetIndex); view.setAlpha(1); view.setTextColor(adapter.getTextSelectedColor()); view.setTextSize(adapter.getTextSize() + 4); adapter.setTextViewPadding(view, adapter.getTextPaddingTop() - 2, adapter.getTextPaddingBottom() - 2); } TextView view = (TextView) itemsLayout.getChildAt(targetIndex - 1); if (view != null) view.setAlpha(1); view = (TextView) itemsLayout.getChildAt(targetIndex + 1); if (view != null) view.setAlpha(1); } itemsLayout.draw(canvas); canvas.restore(); }
From source file:in.silive.bo.sliding.SlidingTabLayout.java
private void populateTabStrip() { Log.d("Strips", "populate TabStrip"); final PagerAdapter adapter = mViewPager.getAdapter(); /* final OnClickListener tabClickListener = new TabClickListener(); */ for (int i = 0; i < adapter.getCount(); i++) { View tabView = null;//from w ww. j a va 2 s . c o m TextView tabTitleView = null; if (mTabViewLayoutId != 0) { // If there is a custom tab view layout id set, try and inflate it tabView = LayoutInflater.from(getContext()).inflate(mTabViewLayoutId, mTabStrip, false); tabTitleView = (TextView) tabView.findViewById(mTabViewTextViewId); // tabTitleView.setTextSize(TypedValue.COMPLEX_UNIT_SP,20); setCustomTabView(tabView.getId(), tabTitleView.getId()); } if (tabView == null) { tabView = createDefaultTabView(getContext()); } if (tabTitleView == null && TextView.class.isInstance(tabView)) { tabTitleView = (TextView) tabView; } if (i == 0) { previousChild = tabTitleView; tabTitleView.setAlpha(1f); } else tabTitleView.setAlpha(0.5f); tabTitleView.setText(adapter.getPageTitle(i)); tabTitleView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 12); //tabView.setOnClickListener(tabClickListener); mTabStrip.addView(tabView); } }
From source file:com.eccyan.widget.SpinningTabStrip.java
private void addTab(final int position, CharSequence title, View tabView) { TextView tabTitle = (TextView) tabView.findViewById(R.id.tab_title); if (tabTitle != null) { if (title != null) { tabTitle.setText(title);// ww w .j a v a2 s. com } float alpha = pager.getCurrentItem() == position ? tabTextSelectedAlpha : tabTextAlpha; tabTitle.setAlpha(alpha); } tabView.setFocusable(true); tabView.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (pager.getCurrentItem() != position) { notSelectedItem(pager.getCurrentItem()); pager.setCurrentItem(position % tabCount); } else if (tabReselectedListener != null) { tabReselectedListener.onTabReselected(position); } } }); tabsContainer.addView(tabView, position, shouldExpand ? expandedTabLayoutParams : defaultTabLayoutParams); }
From source file:br.edu.ifpb.breath.slidingtabs.SlidingTabLayout.java
private void populateTabStrip() { final PagerAdapter adapter = mViewPager.getAdapter(); final OnClickListener tabClickListener = new TabClickListener(); for (int i = 0; i < adapter.getCount(); i++) { View tabView = null;//from w w w .j a v a 2 s.co m TextView tabTitleView = null; ImageView tabIconView = null; if (mTabViewLayoutId != 0) { // If there is a custom tab view layout id set, try and inflate it tabView = LayoutInflater.from(getContext()).inflate(mTabViewLayoutId, mTabStrip, false); tabTitleView = (TextView) tabView.findViewById(mTabViewTextViewId); tabIconView = (ImageView) tabView.findViewById(mTabViewImageViewId); } if (tabView == null && !mUseIcons) { tabView = createDefaultTabView(getContext(), 0); tabView.setAlpha(i == 0 ? 1.0f : 0.25f); } if (tabView == null && mUseIcons) { tabView = createDefaultTabView(getContext(), 1); tabView.setAlpha(i == 0 ? 1.0f : 0.25f); } if (tabTitleView == null && TextView.class.isInstance(tabView)) { tabTitleView = (TextView) tabView; tabTitleView.setAlpha(i == 0 ? 1.0f : 0.25f); } if (tabIconView == null && ImageView.class.isInstance(tabView)) { tabIconView = (ImageView) tabView; tabIconView.setAlpha(i == 0 ? 1.0f : 0.25f); } if (mDistributeEvenly) { LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) tabView.getLayoutParams(); lp.width = 0; lp.weight = 1; } if (mUseIcons) { tabIconView.setVisibility(View.VISIBLE); if (tabTitleView != null) tabTitleView.setVisibility(View.GONE); if (mIcons.containsKey(i)) tabIconView.setImageDrawable(mIcons.get(i)); } else { tabTitleView.setVisibility(View.VISIBLE); if (tabIconView != null) tabIconView.setVisibility(View.GONE); tabTitleView.setText(adapter.getPageTitle(i)); tabTitleView.setTextColor(mTextColor); } tabView.setOnClickListener(tabClickListener); String desc = mContentDescriptions.get(i, null); if (desc != null) { tabView.setContentDescription(desc); } mTabStrip.addView(tabView); if (i == mViewPager.getCurrentItem()) { tabView.setSelected(true); } } }
From source file:com.sj.android.appusage.ui.widgets.SlidingTabLayout.java
private void populateTabStrip() { final PagerAdapter adapter = mViewPager.getAdapter(); final View.OnClickListener tabClickListener = new TabClickListener(); for (int i = 0; i < adapter.getCount(); i++) { View tabView = null;/*from w ww. jav a 2s .c om*/ TextView tabTitleView = null; if (mTabViewLayoutId != 0) { // If there is a custom tab view layout id set, try and inflate it tabView = LayoutInflater.from(getContext()).inflate(mTabViewLayoutId, mTabStrip, false); tabTitleView = (TextView) tabView.findViewById(mTabViewTextViewId); } if (tabView == null) { tabView = createDefaultTabView(getContext()); LinearLayout.LayoutParams tabViewParams = (LinearLayout.LayoutParams) tabView.getLayoutParams(); if (tabViewParams == null) tabViewParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT); tabViewParams.weight = 1; tabView.setLayoutParams(tabViewParams); } if (tabTitleView == null && TextView.class.isInstance(tabView)) { tabTitleView = (TextView) tabView; } if (i == mViewPager.getCurrentItem()) { tabTitleView.setTextColor(Color.WHITE); tabTitleView.setAlpha(1.0f); } else { tabTitleView.setTextColor(Color.WHITE); tabTitleView.setAlpha(0.5f); } tabTitleView.setTextSize(15); tabTitleView.setText(adapter.getPageTitle(i)); tabView.setOnClickListener(tabClickListener); mTabStrip.addView(tabView); } }
From source file:org.mariotaku.twidere.fragment.support.UserFragment.java
private void updateTitleAlpha() { final int[] location = new int[2]; mNameView.getLocationInWindow(location); final float nameShowingRatio = (mHeaderDrawerLayout.getPaddingTop() - location[1]) / (float) mNameView.getHeight(); final float textAlpha = MathUtils.clamp(nameShowingRatio, 0, 1); final ThemedAppCompatActivity activity = (ThemedAppCompatActivity) getActivity(); final Toolbar actionBarView = activity.getActionBarToolbar(); if (actionBarView != null) { final TextView titleView = ViewSupport.findViewByText(actionBarView, actionBarView.getTitle()); if (titleView != null) { titleView.setAlpha(textAlpha); }// w w w .j av a2s . c o m final TextView subtitleView = ViewSupport.findViewByText(actionBarView, actionBarView.getSubtitle()); if (subtitleView != null) { subtitleView.setAlpha(textAlpha); } } }
From source file:org.mariotaku.twidere.fragment.UserFragment.java
private void updateTitleAlpha() { final int[] location = new int[2]; mNameView.getLocationInWindow(location); final float nameShowingRatio = (mHeaderDrawerLayout.getPaddingTop() - location[1]) / (float) mNameView.getHeight(); final float textAlpha = TwidereMathUtils.clamp(nameShowingRatio, 0, 1); final Toolbar actionBarView = mToolbar; if (actionBarView != null) { final TextView titleView = ViewSupport.findViewByText(actionBarView, actionBarView.getTitle()); if (titleView != null) { titleView.setAlpha(textAlpha); }/*from w ww.jav a 2 s.c o m*/ final TextView subtitleView = ViewSupport.findViewByText(actionBarView, actionBarView.getSubtitle()); if (subtitleView != null) { subtitleView.setAlpha(textAlpha); } } }
From source file:com.fastbootmobile.encore.app.fragments.ArtistFragment.java
/** * {@inheritDoc}//from w w w . java2 s . c o m */ @Override @TargetApi(Build.VERSION_CODES.LOLLIPOP) public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { mHandler = new Handler(); // Setup the inside fragments mArtistTracksFragment = new ArtistTracksFragment(); mArtistTracksFragment.setParentFragment(this); mArtistInfoFragment = new ArtistInfoFragment(); mArtistInfoFragment.setArguments(mArtist); mArtistSimilarFragment = new ArtistSimilarFragment(); mArtistSimilarFragment.setArguments(mArtist); // Inflate the main fragment view mRootView = (ParallaxScrollView) inflater.inflate(R.layout.fragment_artist, container, false); // Set the hero image and artist from arguments mHeroImageView = (ImageView) mRootView.findViewById(R.id.ivHero); if (mHeroImage != null) { mHeroImageView.setImageBitmap(mHeroImage); // The hero image that comes from a transition might be low in quality, so load // the higher quality and fade it in loadArt(false); } else { // Display placeholder and try to get the real art mHeroImageView.setImageResource(R.drawable.album_placeholder); loadArt(true); } final TextView tvArtist = (TextView) mRootView.findViewById(R.id.tvArtist); tvArtist.setBackgroundColor(mBackgroundColor); tvArtist.setText(mArtist.getName()); final PagerTabStrip strip = (PagerTabStrip) mRootView.findViewById(R.id.pagerArtistStrip); strip.setDrawFullUnderline(false); strip.setAlpha(0.0f); strip.setTranslationY(-20); strip.animate().alpha(1.0f).setDuration(ANIMATION_DURATION).setStartDelay(500).translationY(0).start(); if (!Utils.hasLollipop()) { tvArtist.setAlpha(0); tvArtist.animate().alpha(1).setDuration(ANIMATION_DURATION).setStartDelay(500).start(); } // Setup the subfragments pager final WrapContentHeightViewPager pager = (WrapContentHeightViewPager) mRootView .findViewById(R.id.pagerArtist); pager.setAdapter(new ViewPagerAdapter(getChildFragmentManager())); pager.setOffscreenPageLimit(FRAGMENT_COUNT); pager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() { @Override public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { } @Override public void onPageSelected(int i) { if (mRootView.getScrollY() > tvArtist.getTop()) { mRootView.smoothScrollTo(0, tvArtist.getTop()); } mHandler.post(new Runnable() { @Override public void run() { pager.setMinimumHeight(500); pager.requestLayout(); } }); boolean hasRosetta = ProviderAggregator.getDefault().getRosettaStonePrefix().size() > 0; if (hasRosetta) { if (i == FRAGMENT_ID_BIOGRAPHY) { mArtistInfoFragment.notifyActive(); } else if (i == FRAGMENT_ID_SIMILAR) { mArtistSimilarFragment.notifyActive(); } } else { if (i == FRAGMENT_ID_SIMILAR) { // This is actually BIOGRAPHY if rosetta is not available mArtistInfoFragment.notifyActive(); } } } @Override public void onPageScrollStateChanged(int i) { } }); mRootView.setOnScrollListener(new ObservableScrollView.ScrollViewListener() { @Override public void onScroll(ObservableScrollView scrollView, int x, int y, int oldx, int oldy) { final ActionBar ab = ((AppActivity) getActivity()).getSupportActionBar(); if (ab != null) { if (y >= tvArtist.getTop()) { ab.hide(); } else { ab.show(); } } } }); // Setup the source logo final ImageView ivSource = (ImageView) mRootView.findViewById(R.id.ivSourceLogo); mLogoBitmap = PluginsLookup.getDefault().getCachedLogo(getResources(), mArtist); ivSource.setImageDrawable(mLogoBitmap); // Outline is required for the FAB shadow to be actually oval mFabPlay = (FloatingActionButton) mRootView.findViewById(R.id.fabPlay); showFab(false, false); // Set the FAB animated drawable mFabDrawable = new PlayPauseDrawable(getResources(), 1); mFabDrawable.setShape(PlayPauseDrawable.SHAPE_PLAY); mFabDrawable.setYOffset(6); final Song currentTrack = PlaybackProxy.getCurrentTrack(); if (currentTrack != null && currentTrack.getArtist() != null && currentTrack.getArtist().equals(mArtist.getRef())) { int state = PlaybackProxy.getState(); if (state == PlaybackService.STATE_PLAYING) { mFabDrawable.setShape(PlayPauseDrawable.SHAPE_PAUSE); } else if (state == PlaybackService.STATE_PAUSED) { mFabShouldResume = true; } else if (state == PlaybackService.STATE_BUFFERING) { mFabDrawable.setShape(PlayPauseDrawable.SHAPE_PLAY); mFabDrawable.setBuffering(true); mFabShouldResume = true; } else if (state == PlaybackService.STATE_PAUSING) { mFabDrawable.setShape(PlayPauseDrawable.SHAPE_PAUSE); mFabDrawable.setBuffering(true); mFabShouldResume = true; } } mFabPlay.setImageDrawable(mFabDrawable); mFabPlay.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (mFabDrawable.getCurrentShape() == PlayPauseDrawable.SHAPE_PLAY) { if (mFabShouldResume) { PlaybackProxy.play(); } else { mArtistTracksFragment.playRecommendation(); } } else { mFabDrawable.setShape(PlayPauseDrawable.SHAPE_PAUSE); mFabShouldResume = true; PlaybackProxy.pause(); } } }); return mRootView; }
From source file:com.android.tv.menu.MenuLayoutManager.java
/** * Move the current selection to the given {@code position} with animation. * The animation specification is included in http://b/21069476 *//*from w w w .j a v a 2 s . c om*/ public void setSelectedPositionSmooth(final int position) { if (DEBUG) { Log.d(TAG, "setSelectedPositionSmooth(position=" + position + ") {previousPosition=" + mSelectedPosition + "}"); } if (mMenuView.getVisibility() != View.VISIBLE) { setSelectedPosition(position); return; } if (mSelectedPosition == position) { return; } boolean oldIndexValid = Utils.isIndexValid(mMenuRowViews, mSelectedPosition); SoftPreconditions.checkState(oldIndexValid, TAG, "No previous selection: " + mSelectedPosition); if (!oldIndexValid) { return; } boolean newIndexValid = Utils.isIndexValid(mMenuRowViews, position); SoftPreconditions.checkArgument(newIndexValid, TAG, "position " + position); if (!newIndexValid) { return; } MenuRow row = mMenuRows.get(position); if (!row.isVisible()) { Log.e(TAG, "Moving to the invisible row: " + position); return; } if (mAnimatorSet != null) { // Do not cancel the animation here. The property values should be set to the end values // when the animation finishes. mAnimatorSet.end(); } if (mTitleFadeOutAnimator != null) { // Cancel the animation instead of ending it in order that the title animation starts // again from the intermediate state. mTitleFadeOutAnimator.cancel(); } final int oldPosition = mSelectedPosition; mSelectedPosition = position; if (DEBUG) dumpChildren("startRowAnimation()"); MenuRowView currentView = mMenuRowViews.get(position); // Show the children of the next row. currentView.getTitleView().setVisibility(View.VISIBLE); currentView.getContentsView().setVisibility(View.VISIBLE); // Request focus after the new contents view shows up. mMenuView.requestFocus(); if (mTempTitleViewForOld == null) { // Initialize here because we don't know when the views are inflated. mTempTitleViewForOld = (TextView) mMenuView.findViewById(R.id.temp_title_for_old); mTempTitleViewForCurrent = (TextView) mMenuView.findViewById(R.id.temp_title_for_current); } // Animations. mPropertyValuesAfterAnimation.clear(); List<Animator> animators = new ArrayList<>(); boolean scrollDown = position > oldPosition; List<Rect> layouts = getViewLayouts(mMenuView.getLeft(), mMenuView.getTop(), mMenuView.getRight(), mMenuView.getBottom()); // Old row. MenuRow oldRow = mMenuRows.get(oldPosition); MenuRowView oldView = mMenuRowViews.get(oldPosition); View oldContentsView = oldView.getContentsView(); // Old contents view. animators.add(createAlphaAnimator(oldContentsView, 1.0f, 0.0f, 1.0f, mLinearOutSlowIn) .setDuration(mOldContentsFadeOutDuration)); final TextView oldTitleView = oldView.getTitleView(); setTempTitleView(mTempTitleViewForOld, oldTitleView); Rect oldLayoutRect = layouts.get(oldPosition); if (scrollDown) { // Old title view. if (oldRow.hideTitleWhenSelected() && oldTitleView.getVisibility() != View.VISIBLE) { // This case is not included in the animation specification. mTempTitleViewForOld.setScaleX(1.0f); mTempTitleViewForOld.setScaleY(1.0f); animators.add(createAlphaAnimator(mTempTitleViewForOld, 0.0f, oldView.getTitleViewAlphaDeselected(), mFastOutLinearIn)); int offset = oldLayoutRect.top - mTempTitleViewForOld.getTop(); animators.add(createTranslationYAnimator(mTempTitleViewForOld, offset + mRowScrollUpAnimationOffset, offset)); } else { animators .add(createScaleXAnimator(mTempTitleViewForOld, oldView.getTitleViewScaleSelected(), 1.0f)); animators .add(createScaleYAnimator(mTempTitleViewForOld, oldView.getTitleViewScaleSelected(), 1.0f)); animators.add(createAlphaAnimator(mTempTitleViewForOld, oldTitleView.getAlpha(), oldView.getTitleViewAlphaDeselected(), mLinearOutSlowIn)); animators.add(createTranslationYAnimator(mTempTitleViewForOld, 0, oldLayoutRect.top - mTempTitleViewForOld.getTop())); } oldTitleView.setAlpha(oldView.getTitleViewAlphaDeselected()); oldTitleView.setVisibility(View.INVISIBLE); } else { Rect currentLayoutRect = new Rect(layouts.get(position)); // Old title view. // The move distance in the specification is 32dp(mRowScrollUpAnimationOffset). // But if the height of the upper row is small, the upper row will move down a lot. In // this case, this row needs to move more than the specification to avoid the overlap of // the two titles. // The maximum is to the top of the start position of mTempTitleViewForOld. int distanceCurrentTitle = currentLayoutRect.top - currentView.getTop(); int distance = Math.max(mRowScrollUpAnimationOffset, distanceCurrentTitle); int distanceToTopOfSecondTitle = oldLayoutRect.top - mRowScrollUpAnimationOffset - oldView.getTop(); animators.add( createTranslationYAnimator(oldTitleView, 0.0f, Math.min(distance, distanceToTopOfSecondTitle))); animators.add(createAlphaAnimator(oldTitleView, 1.0f, 0.0f, 1.0f, mLinearOutSlowIn) .setDuration(mOldContentsFadeOutDuration)); animators.add(createScaleXAnimator(oldTitleView, oldView.getTitleViewScaleSelected(), 1.0f)); animators.add(createScaleYAnimator(oldTitleView, oldView.getTitleViewScaleSelected(), 1.0f)); mTempTitleViewForOld.setScaleX(1.0f); mTempTitleViewForOld.setScaleY(1.0f); animators.add(createAlphaAnimator(mTempTitleViewForOld, 0.0f, oldView.getTitleViewAlphaDeselected(), mFastOutLinearIn)); int offset = oldLayoutRect.top - mTempTitleViewForOld.getTop(); animators.add( createTranslationYAnimator(mTempTitleViewForOld, offset - mRowScrollUpAnimationOffset, offset)); } // Current row. Rect currentLayoutRect = new Rect(layouts.get(position)); TextView currentTitleView = currentView.getTitleView(); View currentContentsView = currentView.getContentsView(); currentContentsView.setAlpha(0.0f); if (scrollDown) { // Current title view. setTempTitleView(mTempTitleViewForCurrent, currentTitleView); // The move distance in the specification is 32dp(mRowScrollUpAnimationOffset). // But if the height of the upper row is small, the upper row will move up a lot. In // this case, this row needs to start the move from more than the specification to avoid // the overlap of the two titles. // The maximum is to the top of the end position of mTempTitleViewForCurrent. int distanceOldTitle = oldView.getTop() - oldLayoutRect.top; int distance = Math.max(mRowScrollUpAnimationOffset, distanceOldTitle); int distanceTopOfSecondTitle = currentView.getTop() - mRowScrollUpAnimationOffset - currentLayoutRect.top; animators.add(createTranslationYAnimator(currentTitleView, Math.min(distance, distanceTopOfSecondTitle), 0.0f)); currentView.setTop(currentLayoutRect.top); ObjectAnimator animator = createAlphaAnimator(currentTitleView, 0.0f, 1.0f, mFastOutLinearIn) .setDuration(mCurrentContentsFadeInDuration); animator.setStartDelay(mOldContentsFadeOutDuration); currentTitleView.setAlpha(0.0f); animators.add(animator); animators.add(createScaleXAnimator(currentTitleView, 1.0f, currentView.getTitleViewScaleSelected())); animators.add(createScaleYAnimator(currentTitleView, 1.0f, currentView.getTitleViewScaleSelected())); animators.add(createTranslationYAnimator(mTempTitleViewForCurrent, 0.0f, -mRowScrollUpAnimationOffset)); animators.add(createAlphaAnimator(mTempTitleViewForCurrent, currentView.getTitleViewAlphaDeselected(), 0, mLinearOutSlowIn)); // Current contents view. animators.add(createTranslationYAnimator(currentContentsView, mRowScrollUpAnimationOffset, 0.0f)); animator = createAlphaAnimator(currentContentsView, 0.0f, 1.0f, mFastOutLinearIn) .setDuration(mCurrentContentsFadeInDuration); animator.setStartDelay(mOldContentsFadeOutDuration); animators.add(animator); } else { currentView.setBottom(currentLayoutRect.bottom); // Current title view. int currentViewOffset = currentLayoutRect.top - currentView.getTop(); animators.add(createTranslationYAnimator(currentTitleView, 0, currentViewOffset)); animators.add(createAlphaAnimator(currentTitleView, currentView.getTitleViewAlphaDeselected(), 1.0f, mFastOutSlowIn)); animators.add(createScaleXAnimator(currentTitleView, 1.0f, currentView.getTitleViewScaleSelected())); animators.add(createScaleYAnimator(currentTitleView, 1.0f, currentView.getTitleViewScaleSelected())); // Current contents view. animators.add(createTranslationYAnimator(currentContentsView, currentViewOffset - mRowScrollUpAnimationOffset, currentViewOffset)); ObjectAnimator animator = createAlphaAnimator(currentContentsView, 0.0f, 1.0f, mFastOutLinearIn) .setDuration(mCurrentContentsFadeInDuration); animator.setStartDelay(mOldContentsFadeOutDuration); animators.add(animator); } // Next row. int nextPosition; if (scrollDown) { nextPosition = findNextVisiblePosition(position); if (nextPosition != -1) { MenuRowView nextView = mMenuRowViews.get(nextPosition); Rect nextLayoutRect = layouts.get(nextPosition); animators.add(createTranslationYAnimator(nextView, nextLayoutRect.top + mRowScrollUpAnimationOffset - nextView.getTop(), nextLayoutRect.top - nextView.getTop())); animators.add(createAlphaAnimator(nextView, 0.0f, 1.0f, mFastOutLinearIn)); } } else { nextPosition = findNextVisiblePosition(oldPosition); if (nextPosition != -1) { MenuRowView nextView = mMenuRowViews.get(nextPosition); animators.add(createTranslationYAnimator(nextView, 0, mRowScrollUpAnimationOffset)); animators.add(createAlphaAnimator(nextView, nextView.getTitleViewAlphaDeselected(), 0.0f, 1.0f, mLinearOutSlowIn)); } } // Other rows. int count = mMenuRowViews.size(); for (int i = 0; i < count; ++i) { MenuRowView view = mMenuRowViews.get(i); if (view.getVisibility() == View.VISIBLE && i != oldPosition && i != position && i != nextPosition) { Rect rect = layouts.get(i); animators.add(createTranslationYAnimator(view, 0, rect.top - view.getTop())); } } // Run animation. final List<ViewPropertyValueHolder> propertyValuesAfterAnimation = new ArrayList<>(); propertyValuesAfterAnimation.addAll(mPropertyValuesAfterAnimation); mAnimatorSet = new AnimatorSet(); mAnimatorSet.playTogether(animators); mAnimatorSet.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animator) { if (DEBUG) dumpChildren("onRowAnimationEndBefore"); mAnimatorSet = null; // The property values which are different from the end values and need to be // changed after the animation are set here. // e.g. setting translationY to 0, alpha of the contents view to 1. for (ViewPropertyValueHolder holder : propertyValuesAfterAnimation) { holder.property.set(holder.view, holder.value); } oldTitleView.setVisibility(View.VISIBLE); mMenuRowViews.get(oldPosition).onDeselected(); mMenuRowViews.get(position).onSelected(true); mTempTitleViewForOld.setVisibility(View.GONE); mTempTitleViewForCurrent.setVisibility(View.GONE); layout(mMenuView.getLeft(), mMenuView.getTop(), mMenuView.getRight(), mMenuView.getBottom()); if (DEBUG) dumpChildren("onRowAnimationEndAfter"); MenuRow currentRow = mMenuRows.get(position); if (currentRow.hideTitleWhenSelected()) { View titleView = mMenuRowViews.get(position).getTitleView(); mTitleFadeOutAnimator = createAlphaAnimator(titleView, titleView.getAlpha(), 0.0f, mLinearOutSlowIn); mTitleFadeOutAnimator.setStartDelay(TITLE_SHOW_DURATION_BEFORE_HIDDEN_MS); mTitleFadeOutAnimator.addListener(new AnimatorListenerAdapter() { private boolean mCanceled; @Override public void onAnimationCancel(Animator animator) { mCanceled = true; } @Override public void onAnimationEnd(Animator animator) { mTitleFadeOutAnimator = null; if (!mCanceled) { mMenuRowViews.get(position).onSelected(false); } } }); mTitleFadeOutAnimator.start(); } } }); mAnimatorSet.start(); if (DEBUG) dumpChildren("startedRowAnimation()"); }