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

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

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

Toolbar.animate介绍

暂无

代码示例

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

/**
 * Initializing pager and fullscreen mode.
 */
private void initPager() {
  // Setting up pager adapter
  pagerAdapter = new PhotoPagerAdapter(views.pager, getSettingsController());
  pagerListener = new ViewPager.SimpleOnPageChangeListener() {
    @Override
    public void onPageSelected(int position) {
      onPhotoInPagerSelected(position);
    }
  };
  views.pager.setAdapter(pagerAdapter);
  views.pager.addOnPageChangeListener(pagerListener);
  views.pager.setPageTransformer(true, new DepthPageTransformer());
  // Setting up pager toolbar
  views.pagerToolbar.setNavigationIcon(R.drawable.ic_arrow_back_white_24dp);
  views.pagerToolbar.setNavigationOnClickListener(view -> onBackPressed());
  // Enabling immersive mode by clicking on full screen image
  pagerAdapter.setImageClickListener(() -> {
    if (!listAnimator.isLeaving()) {
      // Toggle immersive mode
      showSystemUi(!isSystemUiShown());
    }
  });
  getWindow().getDecorView().setOnSystemUiVisibilityChangeListener(
      visibility -> views.pagerToolbar.animate().alpha(isSystemUiShown() ? 1f : 0f));
}

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

/**
 * Animates the visibility of the toolbar, which is shown, when the tab switcher is shown.
 *
 * @param visible
 *         True, if the toolbar should become visible, false otherwise
 * @param delay
 *         The delay of the animation in milliseconds as a {@link Long} value
 */
private void animateToolbarVisibility(final boolean visible, final long delay) {
  if (toolbarAnimation != null) {
    toolbarAnimation.cancel();
  }
  toolbarAnimation = toolbar.animate();
  toolbarAnimation.setInterpolator(new AccelerateDecelerateInterpolator());
  toolbarAnimation.setDuration(toolbarVisibilityAnimationDuration);
  toolbarAnimation.setListener(createToolbarAnimationListener(visible));
  toolbarAnimation.setStartDelay(delay);
  toolbarAnimation.alpha(visible ? 1 : 0);
  toolbarAnimation.start();
}

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

private void animateTranslation(int to, Interpolator interpolator) {
  toolbar.animate()
      .translationY(to)
      .setDuration(ANIMATION_DURATION)
      .setInterpolator(interpolator)
      .setListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
          super.onAnimationEnd(animation);
          isUpdatingTranslation = false;
        }
      })
      .start();
  isUpdatingTranslation = true;
}

相关文章