List of usage examples for android.view View getWidth
@ViewDebug.ExportedProperty(category = "layout") public final int getWidth()
From source file:com.androidinspain.deskclock.alarms.dataadapter.ExpandedAlarmViewHolder.java
private Animator createExpandingAnimator(AlarmItemViewHolder oldHolder, long duration) { final View oldView = oldHolder.itemView; final View newView = itemView; final Animator boundsAnimator = AnimatorUtils.getBoundsAnimator(newView, oldView, newView); boundsAnimator.setDuration(duration); boundsAnimator.setInterpolator(AnimatorUtils.INTERPOLATOR_FAST_OUT_SLOW_IN); final Animator backgroundAnimator = ObjectAnimator.ofPropertyValuesHolder(newView, PropertyValuesHolder.ofInt(AnimatorUtils.BACKGROUND_ALPHA, 0, 255)); backgroundAnimator.setDuration(duration); final View oldArrow = oldHolder.arrow; final Rect oldArrowRect = new Rect(0, 0, oldArrow.getWidth(), oldArrow.getHeight()); final Rect newArrowRect = new Rect(0, 0, arrow.getWidth(), arrow.getHeight()); ((ViewGroup) newView).offsetDescendantRectToMyCoords(arrow, newArrowRect); ((ViewGroup) oldView).offsetDescendantRectToMyCoords(oldArrow, oldArrowRect); final float arrowTranslationY = oldArrowRect.bottom - newArrowRect.bottom; arrow.setTranslationY(arrowTranslationY); arrow.setVisibility(View.VISIBLE); clock.setVisibility(View.VISIBLE); onOff.setVisibility(View.VISIBLE); final long longDuration = (long) (duration * ANIM_LONG_DURATION_MULTIPLIER); final Animator repeatAnimation = ObjectAnimator.ofFloat(repeat, View.ALPHA, 1f).setDuration(longDuration); final Animator repeatDaysAnimation = ObjectAnimator.ofFloat(repeatDays, View.ALPHA, 1f) .setDuration(longDuration);/* w w w .j ava 2 s.c o m*/ final Animator ringtoneAnimation = ObjectAnimator.ofFloat(ringtone, View.ALPHA, 1f) .setDuration(longDuration); final Animator dismissAnimation = ObjectAnimator.ofFloat(preemptiveDismissButton, View.ALPHA, 1f) .setDuration(longDuration); final Animator vibrateAnimation = ObjectAnimator.ofFloat(vibrate, View.ALPHA, 1f).setDuration(longDuration); final Animator editLabelAnimation = ObjectAnimator.ofFloat(editLabel, View.ALPHA, 1f) .setDuration(longDuration); final Animator hairLineAnimation = ObjectAnimator.ofFloat(hairLine, View.ALPHA, 1f) .setDuration(longDuration); final Animator deleteAnimation = ObjectAnimator.ofFloat(delete, View.ALPHA, 1f).setDuration(longDuration); final Animator arrowAnimation = ObjectAnimator.ofFloat(arrow, View.TRANSLATION_Y, 0f).setDuration(duration); arrowAnimation.setInterpolator(AnimatorUtils.INTERPOLATOR_FAST_OUT_SLOW_IN); // Set the stagger delays; delay the first by the amount of time it takes for the collapse // to complete, then stagger the expansion with the remaining time. long startDelay = (long) (duration * ANIM_STANDARD_DELAY_MULTIPLIER); final int numberOfItems = countNumberOfItems(); final long delayIncrement = (long) (duration * ANIM_SHORT_DELAY_INCREMENT_MULTIPLIER) / (numberOfItems - 1); repeatAnimation.setStartDelay(startDelay); startDelay += delayIncrement; final boolean daysVisible = repeatDays.getVisibility() == View.VISIBLE; if (daysVisible) { repeatDaysAnimation.setStartDelay(startDelay); startDelay += delayIncrement; } ringtoneAnimation.setStartDelay(startDelay); vibrateAnimation.setStartDelay(startDelay); startDelay += delayIncrement; editLabelAnimation.setStartDelay(startDelay); startDelay += delayIncrement; hairLineAnimation.setStartDelay(startDelay); if (preemptiveDismissButton.getVisibility() == View.VISIBLE) { dismissAnimation.setStartDelay(startDelay); startDelay += delayIncrement; } deleteAnimation.setStartDelay(startDelay); final AnimatorSet animatorSet = new AnimatorSet(); animatorSet.playTogether(backgroundAnimator, repeatAnimation, boundsAnimator, repeatDaysAnimation, vibrateAnimation, ringtoneAnimation, editLabelAnimation, deleteAnimation, hairLineAnimation, dismissAnimation, arrowAnimation); animatorSet.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationStart(Animator animator) { AnimatorUtils.startDrawableAnimation(arrow); } }); return animatorSet; }
From source file:com.base.app.widget.indicatorview.TabPageIndicator.java
private void animateToTab(final int position) { final View tabView = mTabLayout.getChildAt(position); if (mTabSelector != null) { removeCallbacks(mTabSelector);// w w w . j a v a2s .c om } mTabSelector = new Runnable() { public void run() { final int scrollPos = tabView.getLeft() - (getWidth() - tabView.getWidth()) / 2; smoothScrollTo(scrollPos, 0); mTabSelector = null; } }; post(mTabSelector); }
From source file:com.battlelancer.seriesguide.ui.MoviesBaseFragment.java
@Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { Cursor movie = (Cursor) mAdapter.getItem(position); int tmdbId = movie.getInt(MoviesCursorAdapter.MoviesQuery.TMDB_ID); // launch movie details activity Intent i = new Intent(getActivity(), MovieDetailsActivity.class); i.putExtra(MovieDetailsFragment.InitBundle.TMDB_ID, tmdbId); ActivityCompat.startActivity(getActivity(), i, ActivityOptionsCompat .makeScaleUpAnimation(view, 0, 0, view.getWidth(), view.getHeight()).toBundle()); }
From source file:com.example.admin.news.mvp.ui.activities.PhotoActivity.java
private void startActivity(View view, Intent intent) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { ActivityOptions options = ActivityOptions.makeSceneTransitionAnimation(mActivity, view, Constants.TRANSITION_ANIMATION_NEWS_PHOTOS); startActivity(intent, options.toBundle()); } else {/*w w w . ja va 2 s . c om*/ ActivityOptionsCompat options = ActivityOptionsCompat.makeScaleUpAnimation(view, view.getWidth() / 2, view.getHeight() / 2, 0, 0); ActivityCompat.startActivity(mActivity, intent, options.toBundle()); } }
From source file:com.example.anumbrella.viewpager.TabPagerIndicator.java
/** * tab(tab??)/*from ww w . j av a 2 s. c o m*/ * * @param item */ private void animateToTab(int item) { final View tabView = mTabLayout.getChildAt(item); if (mTabSelector != null) { removeCallbacks(mTabSelector); } mTabSelector = new Runnable() { @Override public void run() { final int scrollPos = tabView.getLeft() - (getWidth() - tabView.getWidth()) / 2; //scrollPos < 0 ? smoothScrollTo(scrollPos, 0); mTabSelector = null; } }; // runnable post(mTabSelector); }
From source file:com.fastbootmobile.encore.app.ArtistActivity.java
@Override @TargetApi(Build.VERSION_CODES.LOLLIPOP) protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_artist); mHandler = new Handler(); FragmentManager fm = getSupportFragmentManager(); mActiveFragment = (ArtistFragment) fm.findFragmentByTag(TAG_FRAGMENT); if (savedInstanceState == null) { mHero = Utils.dequeueBitmap(BITMAP_ARTIST_HERO); mInitialIntent = getIntent().getExtras(); } else {//from w w w .ja v a 2 s .co m mHero = Utils.dequeueBitmap(BITMAP_ARTIST_HERO); mInitialIntent = savedInstanceState.getBundle(EXTRA_RESTORE_INTENT); } if (mActiveFragment == null) { mActiveFragment = new ArtistFragment(); fm.beginTransaction().add(R.id.container, mActiveFragment, TAG_FRAGMENT).commit(); } mActiveFragment.setArguments(mHero, mInitialIntent); // Remove the activity title as we don't want it here mToolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(mToolbar); final ActionBar actionBar = getSupportActionBar(); if (actionBar != null) { actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setHomeButtonEnabled(true); actionBar.setTitle(""); } mIsEntering = true; if (Utils.hasLollipop()) { setEnterSharedElementCallback(new SharedElementCallback() { @Override public void onMapSharedElements(List<String> names, Map<String, View> sharedElements) { View fab = mActiveFragment.findViewById(R.id.fabPlay); fab.setVisibility(View.VISIBLE); // get the center for the clipping circle int cx = fab.getMeasuredWidth() / 2; int cy = fab.getMeasuredHeight() / 2; // get the final radius for the clipping circle final int finalRadius = fab.getWidth(); // create and start the animator for this view // (the start radius is zero) Animator anim; if (mIsEntering) { anim = ViewAnimationUtils.createCircularReveal(fab, cx, cy, 0, finalRadius); } else { anim = ViewAnimationUtils.createCircularReveal(fab, cx, cy, finalRadius, 0); } anim.setInterpolator(new DecelerateInterpolator()); anim.start(); fab.setTranslationX(-fab.getMeasuredWidth() / 4.0f); fab.setTranslationY(-fab.getMeasuredHeight() / 4.0f); fab.animate().translationX(0.0f).translationY(0.0f) .setDuration(getResources().getInteger(android.R.integer.config_shortAnimTime)) .setInterpolator(new DecelerateInterpolator()).start(); final View artistName = mActiveFragment.findViewById(R.id.tvArtist); if (artistName != null) { cx = artistName.getMeasuredWidth() / 4; cy = artistName.getMeasuredHeight() / 2; final int duration = getResources().getInteger(android.R.integer.config_mediumAnimTime); final int radius = Utils.getEnclosingCircleRadius(artistName, cx, cy); if (mIsEntering) { artistName.setVisibility(View.INVISIBLE); Utils.animateCircleReveal(artistName, cx, cy, 0, radius, duration, 300); } else { artistName.setVisibility(View.VISIBLE); Utils.animateCircleReveal(artistName, cx, cy, radius, 0, duration, 0); } } } }); } getWindow().getDecorView() .setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN); }
From source file:com.example.recycleviewexample.ScaleInItemAnimator.java
private void animateRemoveImpl(final ViewHolder holder) { final View view = holder.itemView; ViewCompat.setPivotX(view, view.getWidth()); final ViewPropertyAnimatorCompat animation = ViewCompat.animate(view); animation.setDuration(getRemoveDuration()).scaleX(0).setListener(new VpaListenerAdapter() { @Override//from ww w .j a v a 2 s . c o m public void onAnimationStart(View view) { dispatchRemoveStarting(holder); } @Override public void onAnimationEnd(View view) { animation.setListener(null); ViewCompat.setAlpha(view, 1); dispatchRemoveFinished(holder); mRemoveAnimations.remove(holder); dispatchFinishedWhenDone(); } }).start(); mRemoveAnimations.add(holder); }
From source file:android.support.v17.leanback.widget.DetailsOverviewSharedElementHelper.java
@Override public void onSharedElementStart(List<String> sharedElementNames, List<View> sharedElements, List<View> sharedElementSnapshots) { if (DEBUG) {/* w w w . j av a 2 s. c o m*/ Log.d(TAG, "onSharedElementStart " + mActivityToRunTransition); } if (sharedElements.size() < 1) { return; } View overviewView = sharedElements.get(0); if (mViewHolder == null || mViewHolder.mOverviewFrame != overviewView) { return; } View snapshot = sharedElementSnapshots.get(0); if (hasImageViewScaleChange(snapshot)) { saveImageViewScale(); changeImageViewScale(snapshot); } View imageView = mViewHolder.mImageView; final int width = overviewView.getWidth(); final int height = overviewView.getHeight(); imageView.measure(MeasureSpec.makeMeasureSpec(width, MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(height, MeasureSpec.EXACTLY)); imageView.layout(0, 0, width, height); final View rightPanel = mViewHolder.mRightPanel; if (mRightPanelWidth != 0 && mRightPanelHeight != 0) { rightPanel.measure(MeasureSpec.makeMeasureSpec(mRightPanelWidth, MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(mRightPanelHeight, MeasureSpec.EXACTLY)); rightPanel.layout(width, rightPanel.getTop(), width + mRightPanelWidth, rightPanel.getTop() + mRightPanelHeight); } else { rightPanel.offsetLeftAndRight(width - rightPanel.getLeft()); } mViewHolder.mActionsRow.setVisibility(View.INVISIBLE); mViewHolder.mDetailsDescriptionFrame.setVisibility(View.INVISIBLE); }
From source file:com.example.android.adaptertransition.AdapterTransitionFragment.java
/** * Copy all the visible views in the mAbsListView into a new FrameLayout and return it. * * @return a FrameLayout with all the visible views inside. *//*from w ww.j a v a2 s .com*/ private FrameLayout copyVisibleViews() { // This is the FrameLayout we return afterwards. FrameLayout layout = new FrameLayout(getActivity()); // The transition framework requires to set ID for all views to be animated. layout.setId(ROOT_ID); // We only copy visible views. int first = mAbsListView.getFirstVisiblePosition(); int index = 0; while (true) { // This is one of the views that we copy. Note that the argument for getChildAt is a // zero-oriented index, and it doesn't usually match with its position in the list. View source = mAbsListView.getChildAt(index); if (null == source) { break; } // This is the copy of the original view. View destination = mAdapter.getView(first + index, null, layout); assert destination != null; destination.setId(ROOT_ID + first + index); FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(source.getWidth(), source.getHeight()); params.leftMargin = (int) source.getX(); params.topMargin = (int) source.getY(); layout.addView(destination, params); ++index; } return layout; }
From source file:com.efan.notlonely_android.view.PagerSlidingTabStrip.java
private void scrollToChild(int position, int offset) { ViewGroup tabsLayout = getTabsLayout(); if (tabsLayout != null && tabsLayout.getChildCount() > 0 && position < tabsLayout.getChildCount()) { View view = tabsLayout.getChildAt(position); if (view != null) { int newScrollX = view.getLeft() + offset - getLeftMargin(view); if (position > 0 || offset > 0) { newScrollX -= getWidth() / 2 - getOffset(view.getWidth()) / 2; }//from w w w . j ava 2s.co m if (newScrollX != lastScrollX) { lastScrollX = newScrollX; scrollTo(newScrollX, 0); } } } }