本文整理了Java中androidx.appcompat.widget.Toolbar.getHeight()
方法的一些代码示例,展示了Toolbar.getHeight()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Toolbar.getHeight()
方法的具体详情如下:
包路径:androidx.appcompat.widget.Toolbar
类名称:Toolbar
方法名:getHeight
暂无
代码示例来源:origin: michael-rapp/ChromeLikeTabSwitcher
@Override
public final float getPosition(@NonNull final Axis axis, @NonNull final AbstractItem item) {
Condition.INSTANCE.ensureNotNull(axis, "The axis may not be null");
Condition.INSTANCE.ensureNotNull(item, "The item may not be null");
View view = item.getView();
if (getOrientationInvariantAxis(axis) == Axis.DRAGGING_AXIS) {
Toolbar[] toolbars = getTabSwitcher().getToolbars();
return view.getY() -
(getTabSwitcher().areToolbarsShown() && getTabSwitcher().isSwitcherShown() &&
toolbars != null ?
toolbars[TabSwitcher.PRIMARY_TOOLBAR_INDEX].getHeight() - tabInset :
0) - getTabSwitcherPadding(axis, Gravity.START);
} else {
FrameLayout.LayoutParams layoutParams =
(FrameLayout.LayoutParams) view.getLayoutParams();
return view.getX() - layoutParams.leftMargin - getTabSwitcher().getPaddingLeft() / 2f +
getTabSwitcher().getPaddingRight() / 2f +
(getTabSwitcher().getLayout() == Layout.PHONE_LANDSCAPE &&
getTabSwitcher().isSwitcherShown() ?
stackedTabCount * stackedTabSpacing / 2f : 0);
}
}
代码示例来源:origin: michael-rapp/ChromeLikeTabSwitcher
@Override
public final void setPosition(@NonNull final Axis axis, @NonNull final AbstractItem item,
final float position) {
Condition.INSTANCE.ensureNotNull(axis, "The axis may not be null");
Condition.INSTANCE.ensureNotNull(item, "The item may not be null");
View view = item.getView();
if (getOrientationInvariantAxis(axis) == Axis.DRAGGING_AXIS) {
Toolbar[] toolbars = getTabSwitcher().getToolbars();
view.setY((getTabSwitcher().areToolbarsShown() && getTabSwitcher().isSwitcherShown() &&
toolbars != null ?
toolbars[TabSwitcher.PRIMARY_TOOLBAR_INDEX].getHeight() - tabInset : 0) +
getTabSwitcherPadding(axis, Gravity.START) + position);
} else {
FrameLayout.LayoutParams layoutParams =
(FrameLayout.LayoutParams) view.getLayoutParams();
view.setX(position + layoutParams.leftMargin + getTabSwitcher().getPaddingLeft() / 2f -
getTabSwitcher().getPaddingRight() / 2f -
(getTabSwitcher().getLayout() == Layout.PHONE_LANDSCAPE &&
getTabSwitcher().isSwitcherShown() ?
stackedTabCount * stackedTabSpacing / 2f : 0));
}
}
代码示例来源:origin: michael-rapp/ChromeLikeTabSwitcher
@Override
public final void animatePosition(@NonNull final Axis axis,
@NonNull final ViewPropertyAnimator animator,
@NonNull final AbstractItem item, final float position,
final boolean includePadding) {
Condition.INSTANCE.ensureNotNull(axis, "The axis may not be null");
Condition.INSTANCE.ensureNotNull(animator, "The animator may not be null");
Condition.INSTANCE.ensureNotNull(item, "The item may not be null");
if (getOrientationInvariantAxis(axis) == Axis.DRAGGING_AXIS) {
Toolbar[] toolbars = getTabSwitcher().getToolbars();
animator.y((getTabSwitcher().areToolbarsShown() && getTabSwitcher().isSwitcherShown() &&
toolbars != null ?
toolbars[TabSwitcher.PRIMARY_TOOLBAR_INDEX].getHeight() - tabInset : 0) +
(includePadding ? getTabSwitcherPadding(axis, Gravity.START) : 0) + position);
} else {
View view = item.getView();
FrameLayout.LayoutParams layoutParams =
(FrameLayout.LayoutParams) view.getLayoutParams();
animator.x(position + layoutParams.leftMargin + (includePadding ?
getTabSwitcher().getPaddingLeft() / 2f -
getTabSwitcher().getPaddingRight() / 2f : 0) -
(getTabSwitcher().getLayout() == Layout.PHONE_LANDSCAPE &&
getTabSwitcher().isSwitcherShown() ?
stackedTabCount * stackedTabSpacing / 2f : 0));
}
}
代码示例来源:origin: michael-rapp/ChromeLikeTabSwitcher
@Override
public final float getTabContainerSize(@NonNull final Axis axis, final boolean includePadding) {
Condition.INSTANCE.ensureNotNull(axis, "The axis may not be null");
ViewGroup tabContainer = getTabSwitcher().getTabContainer();
assert tabContainer != null;
FrameLayout.LayoutParams layoutParams =
(FrameLayout.LayoutParams) tabContainer.getLayoutParams();
int padding = !includePadding ? (getTabSwitcherPadding(axis, Gravity.START) +
getTabSwitcherPadding(axis, Gravity.END)) : 0;
Toolbar[] toolbars = getTabSwitcher().getToolbars();
if (getOrientationInvariantAxis(axis) == Axis.DRAGGING_AXIS) {
int toolbarSize =
!includePadding && getTabSwitcher().areToolbarsShown() && toolbars != null ?
toolbars[0].getHeight() - tabInset : 0;
return tabContainer.getHeight() - layoutParams.topMargin - layoutParams.bottomMargin -
padding - toolbarSize;
} else {
return tabContainer.getWidth() - layoutParams.leftMargin - layoutParams.rightMargin -
padding;
}
}
代码示例来源:origin: michael-rapp/ChromeLikeTabSwitcher
@Override
@Nullable
protected final AbstractItem getFocusedItem(final float position) {
AbstractItemIterator iterator =
new ItemIterator.Builder(getTabSwitcher(), viewRecycler).create();
AbstractItem tabItem;
while ((tabItem = iterator.next()) != null) {
if (tabItem.getTag().getState() == State.FLOATING ||
tabItem.getTag().getState() == State.STACKED_START_ATOP) {
Toolbar[] toolbars = getTabSwitcher().getToolbars();
float toolbarHeight = getTabSwitcher().getLayout() != Layout.PHONE_LANDSCAPE &&
getTabSwitcher().areToolbarsShown() && toolbars != null ?
toolbars[TabSwitcher.PRIMARY_TOOLBAR_INDEX].getHeight() - tabInset : 0;
float viewPosition =
getArithmetics().getPosition(Axis.DRAGGING_AXIS, tabItem) + toolbarHeight +
getArithmetics()
.getTabSwitcherPadding(Axis.DRAGGING_AXIS, Gravity.START);
if (viewPosition <= position) {
return tabItem;
}
}
}
return null;
}
代码示例来源:origin: klinker24/Android-DragDismissActivity
animateTranslation(-1 * toolbar.getHeight(), interpolator);
代码示例来源:origin: klinker24/Android-DragDismissActivity
@Override
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
super.onScrolled(recyclerView, dx, dy);
if (Math.abs(dy) < minDistance) {
return;
}
if (dy > 0 && toolbar.getTranslationY() == 0) {
Interpolator interpolator = new AccelerateInterpolator();
if (!isUpdatingTranslation) {
animateTranslation(-1 * toolbar.getHeight(), interpolator);
}
if (transparentBackground && !isUpdatingBackground) {
animateBackgroundColor(transparentColor, primaryColor, interpolator);
transparentBackground = false;
}
} else if (dy < 0 && toolbar.getTranslationY() != 0) {
Interpolator interpolator = new DecelerateInterpolator();
if (!isUpdatingTranslation) {
animateTranslation(0, interpolator);
}
LinearLayoutManager manager = (LinearLayoutManager) recyclerView.getLayoutManager();
int firstItem = manager.findFirstVisibleItemPosition();
if (!transparentBackground && firstItem == 0 && !isUpdatingBackground) {
animateBackgroundColor(primaryColor, transparentColor, interpolator);
transparentBackground = true;
}
}
}
代码示例来源:origin: morogoku/MTweaks-KernelAdiutorMOD
@Override
public void onViewFinished() {
super.onViewFinished();
if (showViewPager() && !hideBanner()) {
mViewPager.setAdapter(mViewPagerAdapter = new ViewPagerAdapter(getChildFragmentManager(),
mViewPagerFragments));
mCirclePageIndicator.setViewPager(mViewPager);
setAppBarLayoutAlpha(0);
adjustScrollPosition();
} else {
mRecyclerView.setPadding(mRecyclerView.getPaddingLeft(), isForeground() ? 0 : mToolBar.getHeight(),
mRecyclerView.getPaddingRight(), mRecyclerView.getPaddingBottom());
mRecyclerView.setClipToPadding(true);
ViewGroup.LayoutParams layoutParams = mViewPagerParent.getLayoutParams();
layoutParams.height = 0;
mViewPagerParent.requestLayout();
setAppBarLayoutAlpha(255);
if (hideBanner()) {
if (showTopFab()) {
mTopFab.hide();
mTopFab = null;
} else if (showBottomFab()) {
mBottomFab.hide();
mBottomFab = null;
}
}
}
}
内容来源于网络,如有侵权,请联系作者删除!