Java Code Examples for com.google.android.material.appbar.AppBarLayout#getHeight()
The following examples show how to use
com.google.android.material.appbar.AppBarLayout#getHeight() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FabOffsetter.java From mimi-reader with Apache License 2.0 | 6 votes |
@Override public void onOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) { // fab should scroll out down in sync with the appBarLayout scrolling out up. // let's see how far along the way the appBarLayout is // (if displacementFraction == 0.0f then no displacement, appBar is fully expanded; // if displacementFraction == 1.0f then full displacement, appBar is totally collapsed) float displacementFraction = -verticalOffset / (float) appBarLayout.getHeight(); // need to separate translationY on the fab that comes from this behavior // and one that comes from other sources // translationY from this behavior is stored in a tag on the fab float translationYFromThis = coalesce((Float) fab.getTag(R.id.fab_translationY_from_AppBarBoundFabBehavior), 0f); // top position, accounting for translation not coming from this behavior // float topUntranslatedFromThis = fab.getTop() + fab.getTranslationY() - translationYFromThis; // total length to displace by (from position uninfluenced by this behavior) for a full appBar collapse float fullDisplacement = parent.getBottom() - parent.getPaddingBottom(); // calculate and store new value for displacement coming from this behavior float newTranslationYFromThis = fullDisplacement * displacementFraction; fab.setTag(R.id.fab_translationY_from_AppBarBoundFabBehavior, newTranslationYFromThis); // update translation value by difference found in this step fab.setTranslationY(newTranslationYFromThis - translationYFromThis + fab.getTranslationY()); }
Example 2
Source File: AppBarLayoutOverScrollViewBehavior.java From AndroidAnimationExercise with Apache License 2.0 | 5 votes |
private void initial(AppBarLayout abl) { abl.setClipChildren(false); mParentHeight = abl.getHeight(); mTargetViewHeight = mTargetView.getHeight(); Log.e(TAG, "initial: mParentHeight==" + mParentHeight); Log.e(TAG, "initial: mTargetViewHeight==" + mTargetViewHeight); // mMiddleHeight = middleLayout.getHeight(); }
Example 3
Source File: AppBarLayoutMatchers.java From material-components-android with Apache License 2.0 | 5 votes |
/** Returns a matcher that matches AppBarLayouts which are collapsed. */ public static Matcher<View> isCollapsed() { return new BoundedMatcher<View, AppBarLayout>(AppBarLayout.class) { @Override public void describeTo(Description description) { description.appendText("AppBarLayout is collapsed"); } @Override protected boolean matchesSafely(AppBarLayout item) { return item.getBottom() == (item.getHeight() - item.getTotalScrollRange()); } }; }
Example 4
Source File: AppBarLayoutOverScrollViewBehavior.java From CrazyDaily with Apache License 2.0 | 4 votes |
private void initial(AppBarLayout abl) { abl.setClipChildren(false); mParentHeight = abl.getHeight(); mTargetViewHeight = mTargetView.getHeight(); }
Example 5
Source File: AppBarLayoutOverScrollViewBehavior.java From MultiTypeRecyclerViewAdapter with Apache License 2.0 | 4 votes |
private void initial(AppBarLayout abl) { abl.setClipChildren(false); mParentHeight = abl.getHeight(); mTargetViewHeight = mTargetView.getHeight(); }