androidx.appcompat.widget.Toolbar.getLayoutParams()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(4.7k)|赞(0)|评价(0)|浏览(140)

本文整理了Java中androidx.appcompat.widget.Toolbar.getLayoutParams()方法的一些代码示例,展示了Toolbar.getLayoutParams()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Toolbar.getLayoutParams()方法的具体详情如下:
包路径:androidx.appcompat.widget.Toolbar
类名称:Toolbar
方法名:getLayoutParams

Toolbar.getLayoutParams介绍

暂无

代码示例

代码示例来源:origin: niorgai/StatusBarCompat

CollapsingToolbarLayout.LayoutParams lp = (CollapsingToolbarLayout.LayoutParams) toolbar.getLayoutParams();
int statusBarHeight = getStatusBarHeight(activity);
lp.height += statusBarHeight;

代码示例来源:origin: niorgai/StatusBarCompat

CollapsingToolbarLayout.LayoutParams lp = (CollapsingToolbarLayout.LayoutParams) toolbar.getLayoutParams();
int statusBarHeight = getStatusBarHeight(activity);
lp.height += statusBarHeight;

代码示例来源:origin: daniel-stoneuk/material-about-library

protected void setScrollToolbar(boolean scrollToolbar) {
  if (toolbar != null) {
    AppBarLayout.LayoutParams params =
        (AppBarLayout.LayoutParams) toolbar.getLayoutParams();
    if (scrollToolbar) {
      params.setScrollFlags(AppBarLayout.LayoutParams.SCROLL_FLAG_SCROLL
          | AppBarLayout.LayoutParams.SCROLL_FLAG_ENTER_ALWAYS);
    } else {
      params.setScrollFlags(0);
    }
  }
}

代码示例来源:origin: michael-rapp/ChromeLikeTabSwitcher

/**
 * Adapts the margin of the toolbar, which is shown, when the tab switcher is shown.
 */
private void adaptToolbarMargin() {
  FrameLayout.LayoutParams layoutParams =
      (FrameLayout.LayoutParams) toolbar.getLayoutParams();
  layoutParams.setMargins(getModel().getPaddingLeft(), getModel().getPaddingTop(),
      getModel().getPaddingRight(), 0);
}

代码示例来源:origin: michael-rapp/ChromeLikeTabSwitcher

/**
 * Adapts the margins of the tab container and the toolbars.
 */
private void adaptTabContainerAndToolbarMargins() {
  FrameLayout.LayoutParams tabContainerLayoutParams =
      (FrameLayout.LayoutParams) tabContainer.getLayoutParams();
  tabContainerLayoutParams.setMargins(getModel().getPaddingLeft(), getModel().getPaddingTop(),
      getModel().getPaddingRight(), 0);
  FrameLayout.LayoutParams primaryToolbarLayoutParams =
      (FrameLayout.LayoutParams) primaryToolbar.getLayoutParams();
  primaryToolbarLayoutParams
      .setMargins(getModel().getPaddingLeft(), 0, getModel().getPaddingRight(), 0);
  FrameLayout.LayoutParams secondaryToolbarLayoutParams =
      (FrameLayout.LayoutParams) secondaryToolbar.getLayoutParams();
  secondaryToolbarLayoutParams
      .setMargins(getModel().getPaddingLeft(), 0, getModel().getPaddingRight(), 0);
}

代码示例来源:origin: jruesga/rview

@BindingAdapter("toolbarScrollFlags")
public static void toolbarScrollFlags(Toolbar toolbar, boolean hasTabs) {
  AppBarLayout.LayoutParams params = ((AppBarLayout.LayoutParams) toolbar.getLayoutParams());
  params.setScrollFlags(hasTabs ? AppBarLayout.LayoutParams.SCROLL_FLAG_SCROLL
      | AppBarLayout.LayoutParams.SCROLL_FLAG_ENTER_ALWAYS : 0);
}

代码示例来源:origin: pranavpandey/dynamic-support

/**
 * Set layout scroll flags for the toolbar.
 * <p>Useful to change the collapse mode dynamically.
 *
 * @param flags The scroll flags for the collapsing toolbar layout.
 */
public void setToolbarLayoutFlags(@AppBarLayout.LayoutParams.ScrollFlags int flags) {
  if (mToolbar != null) {
    AppBarLayout.LayoutParams params = (AppBarLayout.LayoutParams)
        mToolbar.getLayoutParams();
    params.setScrollFlags(flags);
    mToolbar.setLayoutParams(params);
  }
}

代码示例来源:origin: michael-rapp/AndroidPreferenceActivity

/**
 * Inflates the view's layout.
 */
private void inflate() {
  inflate(getContext(), R.layout.toolbar_large, this);
  this.backgroundView = findViewById(R.id.toolbar_background_view);
  this.toolbar = findViewById(R.id.navigation_toolbar);
  RelativeLayout.LayoutParams layoutParams =
      (RelativeLayout.LayoutParams) toolbar.getLayoutParams();
  this.navigationWidth = layoutParams.width;
}

代码示例来源:origin: michael-rapp/AndroidPreferenceActivity

/**
 * Sets the width of the navigation.
 *
 * @param width
 *         The width, which should be set, in pixels as an {@link Integer} value. The width must
 *         be greater than 0
 */
public final void setNavigationWidth(@Px final int width) {
  Condition.INSTANCE.ensureGreater(width, 0, "The width must be greater than 0");
  this.navigationWidth = width;
  if (!isNavigationHidden()) {
    RelativeLayout.LayoutParams layoutParams =
        (RelativeLayout.LayoutParams) toolbar.getLayoutParams();
    layoutParams.width = width;
    toolbar.requestLayout();
  }
}

代码示例来源:origin: klinker24/Android-DragDismissActivity

private void setupToolbar() {
  activity.setSupportActionBar(toolbar);
  if (activity.getSupportActionBar() != null) {
    activity.getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    activity.getSupportActionBar().setHomeAsUpIndicator(R.drawable.dragdismiss_ic_close);
    activity.getSupportActionBar().setTitle(toolbarTitle);
  }
  if (!shouldShowToolbar) {
    toolbar.setVisibility(View.GONE);
  }
  int statusBarHeight = StatusBarHelper.getStatusBarHeight(activity);
  statusBar.getLayoutParams().height = statusBarHeight;
  if (appBarLayout == null) {
    ((CoordinatorLayout.LayoutParams) toolbar.getLayoutParams()).topMargin = statusBarHeight;
  } else {
    ((CoordinatorLayout.LayoutParams) appBarLayout.getLayoutParams()).topMargin = statusBarHeight;
  }
}

相关文章