android.support.v7.widget.Toolbar.setBackground()方法的使用及代码示例

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

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

Toolbar.setBackground介绍

暂无

代码示例

代码示例来源:origin: GrenderG/Color-O-Matic

void updateToolbar(int oldColor, int newColor) {
  final TransitionDrawable transition = new TransitionDrawable(new ColorDrawable[]{
      new ColorDrawable(oldColor), new ColorDrawable(newColor)
  });
  if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
    toolbar.setBackground(transition);
  } else {
    toolbar.setBackgroundDrawable(transition);
  }
  transition.startTransition(300);
}

代码示例来源:origin: whyalwaysmea/BigBoom

@Override
protected void initView() {
  mToolbar.setBackground(mContext.getResources().getDrawable(R.drawable.toolbar_drak_bg));
  mPhotoAdapter = new PhotoAdapter();
  RxViewPager.pageSelections(mViewPager).subscribe(new Action1<Integer>() {
    @Override
    public void call(Integer page) {
      if(mCastPhoto != null) {
        if( (page + 1) >= totalSize) {
          mPresenter.getCastPhoto(mId, start);
        }
        mToolbar.setTitle("(" + (page + 1 )+ "/" + mCastPhoto.getTotal() + ")");
      }
    }
  });
}

代码示例来源:origin: Kunzisoft/AndroidClearChroma

private void updateToolbarAndStatusBar(int newColor) {
  if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
    toolbar.setBackground(new ColorDrawable(newColor));
  }
  else {
    toolbar.setBackgroundDrawable(new ColorDrawable(newColor));
  }
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
    getWindow().setStatusBarColor(darkenColor(newColor));
  }
}

代码示例来源:origin: whyalwaysmea/BigBoom

@Override
protected void initView() {
  mToolbar.setBackground(mContext.getResources().getDrawable(R.drawable.toolbar_drak_bg));
  setSupportActionBar(mToolbar);
  mToolbar.setNavigationIcon(R.drawable.icon_back);
  mToolbar.setNavigationOnClickListener(v -> finish());
  mPhotoAdapter = new PhotoAdapter();
  mViewPager.setAdapter(mPhotoAdapter);
}

相关文章

Toolbar类方法