height = TypedValue.complexToDimensionPixelSize(tv.data, getResources().getDisplayMetrics()); }else{ height = bar.getHeight();
height = TypedValue.complexToDimensionPixelSize(tv.data, getResources().getDisplayMetrics()); }else{ height = bar.getHeight();
height = TypedValue.complexToDimensionPixelSize(tv.data, getResources().getDisplayMetrics()); }else{ height = bar.getHeight();
height = TypedValue.complexToDimensionPixelSize(tv.data, getResources().getDisplayMetrics()); }else{ height = bar.getHeight();
height = TypedValue.complexToDimensionPixelSize(tv.data, getResources().getDisplayMetrics()); }else{ height = bar.getHeight();
height = TypedValue.complexToDimensionPixelSize(tv.data, getResources().getDisplayMetrics()); }else{ height = bar.getHeight();
height = TypedValue.complexToDimensionPixelSize(tv.data, getResources().getDisplayMetrics()); } else { height = toolbar.getHeight();
private int getBottomSheetMaximumHeight() { // get toolbar height Toolbar toolbar = (Toolbar) getActivity().findViewById(R.id.toolbar); int toolbarHeight = toolbar.getHeight(); //get status bar height Rect rectangle = new Rect(); Window window = getActivity().getWindow(); window.getDecorView().getWindowVisibleDisplayFrame(rectangle); int windowHeight = rectangle.bottom; // material design recommended bottomsheet padding from actionbar final int padding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,8, getContext().getResources().getDisplayMetrics()); // maximum height of the bottomsheet return windowHeight - toolbarHeight - rectangle.top - padding; }`
public class CardViewElevationOffsetListener implements AppBarLayout.OnOffsetChangedListener { private final CardView mCardView; private float mTargetElevation; private int mToolbarHeight; public CardViewElevationOffsetListener(Toolbar toolbar, CardView cardView) { mToolbarHeight = toolbar.getHeight(); mCardView = cardView; mTargetElevation = ViewCompat.getElevation(cardView); ViewCompat.setElevation(cardView, 0); } @TargetApi(Build.VERSION_CODES.LOLLIPOP) @Override public void onOffsetChanged(AppBarLayout appBarLayout, int offset) { offset = Math.abs(offset); if (offset >= appBarLayout.getTotalScrollRange() - mToolbarHeight) { float flexibleSpace = appBarLayout.getTotalScrollRange() - offset; float ratio = 1 - (flexibleSpace / mToolbarHeight); float elevation = ratio * mTargetElevation; ViewCompat.setElevation(mCardView, elevation); } else { ViewCompat.setElevation(mCardView,0); } } }
public boolean isAppBarCollapsed() { final int appBarVisibleHeight = (int) (mAppBarLayout.getY() + mAppBarLayout.getHeight()); final int toolbarHeight = mToolbar.getHeight(); return (appBarVisibleHeight == toolbarHeight);
@Override public void onInsetsChanged(Rect insets) { Toolbar toolbar = this.toolbar; ViewGroup.MarginLayoutParams lp = (ViewGroup.MarginLayoutParams) toolbar.getLayoutParams(); lp.topMargin = insets.top; int top = insets.top; insets.top += toolbar.getHeight(); toolbar.setLayoutParams(lp); insets.top = top; // revert }
@Override public void onInsetsChanged(Rect insets) { Toolbar toolbar = this.toolbar; ViewGroup.MarginLayoutParams lp = (ViewGroup.MarginLayoutParams) toolbar.getLayoutParams(); lp.topMargin = insets.top; int top = insets.top; insets.top += toolbar.getHeight(); toolbar.setLayoutParams(lp); insets.top = top; // revert }
ShowCaseUtil.showForToolbar(getActivity(), ((MainActivity) getActivity()).toolbar, //instance of my toolbar R.string.showcase_fragment_message, menu.findItem(R.id.action_scan_barcode)); public static void showForToolbar(FragmentActivity activity, final Toolbar toolbar, int message, final MenuItem menuItem) { Target homeTarget = new Target() { @Override public Point getPoint() { int actionBarWidth = toolbar.getWidth(); int y = actionBarWidth - (menuItem.getIcon().getIntrinsicWidth() * menuItem.getOrder()); return new Point(y, toolbar.getHeight()); } }; new ShowcaseView.Builder(activity) .withMaterialShowcase() .setStyle(R.style.CustomShowcaseTheme2) .setTarget(homeTarget) .setContentText(message) .build() .show(); }
@Override public void run() { mToolbarHeight = mToolbar.getHeight(); if (mToolbar != null) { float offset = mToolbar.getTranslationY() - dy; if (offset <= 0 && offset >= -(mToolbar.getHeight())) { mToolbar.setTranslationY(mToolbar.getTranslationY() - dy); FrameLayout.LayoutParams params1 = (FrameLayout.LayoutParams) mCoordinatorLayout.getLayoutParams(); if (RecyclerView.SCROLL_STATE_IDLE == newState) { if(mToolbar != null) { if (Math.abs(mToolbar.getTranslationY()) <= mToolbar.getHeight() / 2) { ObjectAnimator animator = ObjectAnimator.ofFloat(mToolbar, View.TRANSLATION_Y, mToolbar.getTranslationY(), 0); animator.setDuration(300);
final int saveCount = canvas.save(); final int toolbarHeight = mToolbar.getHeight(); canvas.clipRect(0, 0, canvas.getWidth(), interpolate(canvas.getHeight(), toolbarHeight, mScrollOffset));