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

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

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

Toolbar.setVisibility介绍

暂无

代码示例

代码示例来源:origin: alexvasilkov/GestureViews

/**
 * Applying top image animation state: fading out toolbar and background.
 */
private void applyFullImageState(float position, boolean isLeaving) {
  views.fullBackground.setVisibility(position == 0f ? View.INVISIBLE : View.VISIBLE);
  views.fullBackground.setAlpha(position);
  views.fullImageToolbar.setVisibility(position == 0f ? View.INVISIBLE : View.VISIBLE);
  views.fullImageToolbar.setAlpha(position);
  views.fullImage.setVisibility(position == 0f && isLeaving
      ? View.INVISIBLE : View.VISIBLE);
}

代码示例来源:origin: alexvasilkov/GestureViews

/**
 * Applying pager image animation state: fading out toolbar, title and background.
 */
private void applyFullPagerState(float position, boolean isLeaving) {
  views.fullBackground.setVisibility(position == 0f ? View.INVISIBLE : View.VISIBLE);
  views.fullBackground.setAlpha(position);
  views.pagerToolbar.setVisibility(position == 0f ? View.INVISIBLE : View.VISIBLE);
  views.pagerToolbar.setAlpha(isSystemUiShown() ? position : 0f);
  views.pagerTitle.setVisibility(position == 1f ? View.VISIBLE : View.INVISIBLE);
  if (isLeaving && position == 0f) {
    pagerAdapter.setActivated(false);
    showSystemUi(true);
  }
}

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

@Override
public void onAnimationEnd(final Animator animation) {
  super.onAnimationEnd(animation);
  if (!show) {
    toolbar.setVisibility(View.INVISIBLE);
  }
}

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

@Override
public void onAnimationStart(final Animator animation) {
  super.onAnimationStart(animation);
  if (show) {
    toolbar.setVisibility(View.VISIBLE);
  }
}

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

@Override
public void onShowTab(@NonNull final Context context,
           @NonNull final TabSwitcher tabSwitcher, @NonNull final View view,
           @NonNull final Tab tab, final int index, final int viewType,
           @Nullable final State state,
           @Nullable final Bundle savedInstanceState) {
  TextView textView = findViewById(android.R.id.title);
  textView.setText(tab.getTitle());
  Toolbar toolbar = findViewById(R.id.toolbar);
  toolbar.setVisibility(tabSwitcher.isSwitcherShown() ? View.GONE : View.VISIBLE);
  if (viewType == 1) {
    EditText editText = findViewById(android.R.id.edit);
    if (savedInstanceState == null) {
      editText.setText(null);
    }
    editText.requestFocus();
  } else if (viewType == 2 && state != null) {
    ListView listView = findViewById(android.R.id.list);
    state.loadItems(listView);
  }
}

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

/**
 * Adapts the visibility of the toolbars, which are shown, when the tab switcher is shown.
 */
private void adaptToolbarVisibility() {
  Toolbar[] toolbars = getToolbars();
  if (toolbars != null) {
    for (Toolbar toolbar : toolbars) {
      toolbar.setVisibility(
          getTabSwitcher().isSwitcherShown() && getModel().areToolbarsShown() ?
              View.VISIBLE : View.INVISIBLE);
    }
  }
  // TODO: Detach and re-inflate layout
}

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

/**
 * Hides or shows the navigation.
 *
 * @param navigationHidden
 *         True, if the navigation should be hidden, false otherwise
 */
public final void hideNavigation(final boolean navigationHidden) {
  toolbar.setVisibility(navigationHidden ? View.INVISIBLE : View.VISIBLE);
  if (!navigationHidden) {
    setNavigationWidth(navigationWidth);
  }
}

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

/**
 * Set the toolbar or collapsing toolbar layout visibility (collectively known as app bar)
 * if available.
 *
 * @param appBarVisible {@code true} to make the app bar visible.
 */
public void setAppBarVisible(boolean appBarVisible) {
  mAppBarVisible = appBarVisible;
  if (mCollapsingToolbarLayout != null) {
    mCollapsingToolbarLayout.setVisibility(
        appBarVisible ? View.VISIBLE : View.GONE);
  } else {
    mToolbar.setVisibility(appBarVisible ? View.VISIBLE : View.GONE);
  }
}

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

/**
 * Adapts the visibility of the toolbar, which is used to show the breadcrumb of the currently
 * selected navigation preference.
 *
 * @param hideBreadCrumb
 *         True, if the toolbar, which is used to show the bread crumb of the currently selected
 *         navigation preference, should be hidden, false otherwise
 */
private void adaptBreadCrumbVisibility(final boolean hideBreadCrumb) {
  if (isSplitScreen()) {
    if (breadCrumbToolbar != null && breadCrumbShadowView != null) {
      breadCrumbToolbar.setVisibility(hideBreadCrumb ? View.GONE : View.VISIBLE);
      breadCrumbShadowView.setVisibility(hideBreadCrumb ? View.GONE : View.VISIBLE);
    }
  } else {
    if (toolbar != null && toolbarShadowView != null) {
      toolbar.setVisibility(hideBreadCrumb ? View.GONE : View.VISIBLE);
      toolbarShadowView.setVisibility(hideBreadCrumb ? View.GONE : View.VISIBLE);
    }
  }
}

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

@Override
public final void onGlobalLayout() {
  if (getModel().isSwitcherShown()) {
    AbstractItem[] items = calculateInitialItems(getModel().getReferenceTabIndex(),
        getModel().getReferenceTabPosition());
    AbstractItemIterator iterator = new InitialItemIteratorBuilder(items).create();
    AbstractItem item;
    while ((item = iterator.next()) != null) {
      if (item.isVisible()) {
        inflateAndUpdateView(item, false, createBottomMarginLayoutListener(item));
      }
    }
  } else if (getModel().getSelectedTab() != null) {
    AbstractItem item = TabItem.create(getTabSwitcher(), tabViewRecycler,
        getModel().getSelectedTabIndex());
    tabViewRecycler.inflate(item);
  }
  boolean showToolbar = getModel().areToolbarsShown() &&
      (getModel().isEmpty() || getModel().isSwitcherShown());
  toolbar.setAlpha(showToolbar ? 1 : 0);
  toolbar.setVisibility(showToolbar ? View.VISIBLE : View.INVISIBLE);
  adaptEmptyView(0);
}

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

/**
 * Initializes the activity's toolbar.
 */
private void initializeToolbar() {
  Condition.INSTANCE.ensureTrue(getSupportActionBar() == null,
      "An action bar is already attached to the activity. Use the theme " +
          "\"@style/Theme.MaterialComponents.NoActionBar\" or " +
          "\"@style/Theme.MaterialComponents.Light.NoActionBar\" as the activity's theme",
      IllegalStateException.class);
  if (isSplitScreen()) {
    toolbarLarge.setVisibility(View.VISIBLE);
  } else {
    toolbar.setVisibility(View.VISIBLE);
  }
  setSupportActionBar(toolbar);
  resetTitle();
}

代码示例来源: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;
  }
}

代码示例来源:origin: MFlisar/changelog

@Override
public void onCreate(Bundle savedInstanceState) {
  int theme = getIntent().getIntExtra("theme", -1);
  if (theme > 0) {
    setTheme(theme);
  }
  super.onCreate(savedInstanceState);
  setContentView(R.layout.changelog_activity);
  mBuilder = getIntent().getParcelableExtra("builder");
  Toolbar toolbar = findViewById(R.id.toolbar);
  boolean themeHasActionBar = getIntent().getBooleanExtra("themeHasActionBar", false);
  if (!themeHasActionBar) {
    setSupportActionBar(toolbar);
  } else {
    toolbar.setVisibility(View.GONE);
  }
  String title = mBuilder.getCustomTitle();
  if (title == null) {
    title = getString(R.string.changelog_dialog_title, ChangelogUtil.getAppVersionName(this));
  }
  getSupportActionBar().setTitle(title);
  getSupportActionBar().setDisplayHomeAsUpEnabled(true);
  ProgressBar pb = findViewById(R.id.pbLoading);
  RecyclerView rv = findViewById(R.id.rvChangelog);
  ChangelogRecyclerViewAdapter adapter = mBuilder.setupEmptyRecyclerView(rv);
  mAsyncTask = new ChangelogParserAsyncTask(this, pb, adapter, mBuilder);
  mAsyncTask.execute();
}

相关文章