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

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

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

Toolbar.setBackgroundColor介绍

暂无

代码示例

代码示例来源:origin: scwang90/SmartRefreshLayout

@Override
  public void onScrollChange(NestedScrollView v, int scrollX, int scrollY, int oldScrollX, int oldScrollY) {
    if (lastScrollY < h) {
      scrollY = Math.min(h, scrollY);
      mScrollY = scrollY > h ? h : scrollY;
      buttonBar.setAlpha(1f * mScrollY / h);
      toolbar.setBackgroundColor(((255 * mScrollY / h) << 24) | color);
      parallax.setTranslationY(mOffset - mScrollY);
    }
    lastScrollY = scrollY;
  }
});

代码示例来源:origin: naman14/Timber

@Override
public void onResume() {
  super.onResume();
  toolbar.setBackgroundColor(Color.TRANSPARENT);
}

代码示例来源:origin: HotBitmapGG/bilibili-android-client

@Override
  public void onScrollChange(NestedScrollView v, int scrollX, int scrollY, int oldScrollX, int oldScrollY) {
    //根据NestedScrollView滑动改变Toolbar的透明度
    float offsetY = toolBarHeight - imageHeight;
    //计算滑动距离的偏移量
    float offset = 1 - Math.max((offsetY - scrollY) / offsetY, 0f);
    float absOffset = Math.abs(offset);
    //如果滑动距离大于1就设置完全不透明
    if (absOffset >= 1) {
      absOffset = 1;
    }
    mToolbar.setBackgroundColor(Color.argb((int) (absOffset * 255), 251, 114, 153));
  }
});

代码示例来源:origin: florent37/MaterialViewPager

@Override
  public void onAnimationUpdate(ValueAnimator animation) {
    final int animatedValue = (Integer) animation.getAnimatedValue();
    int colorAlpha = colorWithAlpha(animatedValue, lastPercent);
    mHeader.headerBackground.setBackgroundColor(colorAlpha);
    mHeader.statusBackground.setBackgroundColor(colorAlpha);
    mHeader.toolbar.setBackgroundColor(colorAlpha);
    mHeader.toolbarLayoutBackground.setBackgroundColor(colorAlpha);
    mHeader.mPagerSlidingTabStrip.setBackgroundColor(colorAlpha);
    //set the new color as MaterialViewPager's color
    settings.color = animatedValue;
  }
});

代码示例来源:origin: aa112901/remusic

@Override
public void setBackgroundColor(int color) {
  super.setBackgroundColor(color);
  if (mBackgroundHelper != null) {
    mBackgroundHelper.setBackgroundColor(color);
  }
}

代码示例来源:origin: xinghongfei/LookLook

private void setThemeColor(int color) {
  getWindow().setStatusBarColor(color);
  toolbar.setBackgroundColor(color);
}

代码示例来源:origin: aa112901/remusic

@Override
public void onResume() {
  super.onResume();
  toolbar.setBackgroundColor(Color.TRANSPARENT);
  reloadAdapter();
  IntentFilter f = new IntentFilter();
  f.addAction(IConstants.MUSIC_COUNT_CHANGED);
  f.addAction(IConstants.PLAYLIST_ITEM_MOVED);
  f.addAction(MediaService.META_CHANGED);
  getActivity().registerReceiver(mStatusListener, f);
}

代码示例来源:origin: aa112901/remusic

@Override
public void onResume() {
  super.onResume();
  toolbar.setBackgroundColor(Color.TRANSPARENT);
  reloadAdapter();
}

代码示例来源:origin: Yalantis/uCrop

/**
 * Configures and styles both status bar and toolbar.
 */
private void setupAppBar() {
  setStatusBarColor(mStatusBarColor);
  final Toolbar toolbar = findViewById(R.id.toolbar);
  // Set all of the Toolbar coloring
  toolbar.setBackgroundColor(mToolbarColor);
  toolbar.setTitleTextColor(mToolbarWidgetColor);
  final TextView toolbarTitle = toolbar.findViewById(R.id.toolbar_title);
  toolbarTitle.setTextColor(mToolbarWidgetColor);
  toolbarTitle.setText(mToolbarTitle);
  // Color buttons inside the Toolbar
  Drawable stateButtonDrawable = ContextCompat.getDrawable(this, mToolbarCancelDrawable).mutate();
  stateButtonDrawable.setColorFilter(mToolbarWidgetColor, PorterDuff.Mode.SRC_ATOP);
  toolbar.setNavigationIcon(stateButtonDrawable);
  setSupportActionBar(toolbar);
  final ActionBar actionBar = getSupportActionBar();
  if (actionBar != null) {
    actionBar.setDisplayShowTitleEnabled(false);
  }
}

代码示例来源:origin: naman14/Timber

@Override
public void onResume() {
  super.onResume();
  toolbar.setBackgroundColor(Color.TRANSPARENT);
  if (primaryColor != -1 && getActivity() != null) {
    collapsingToolbarLayout.setContentScrimColor(primaryColor);
    String ateKey = Helpers.getATEKey(getActivity());
    ATEUtils.setStatusBarColor(getActivity(), ateKey, primaryColor);
  }
}

代码示例来源:origin: naman14/Timber

@Override
public void onResume() {
  super.onResume();
  String ateKey = Helpers.getATEKey(getActivity());
  toolbar.setBackgroundColor(Color.TRANSPARENT);
  if (primaryColor != -1 && getActivity() != null) {
    collapsingToolbarLayout.setContentScrimColor(primaryColor);
    ATEUtils.setFabBackgroundTint(fab, primaryColor);
    ATEUtils.setStatusBarColor(getActivity(), ateKey, primaryColor);
  }
}

代码示例来源:origin: HotBitmapGG/bilibili-android-client

mToolbar.setBackgroundColor(Color.argb(0, 251, 114, 153));

代码示例来源:origin: iMeiji/Toutiao

@Override
  public void onStateChanged(AppBarLayout appBarLayout, AppBarStateChangeListener.State state) {
    Window window = null;
    if (getActivity() != null && getActivity().getWindow() != null) {
      window = getActivity().getWindow();
    }
    if (state == State.EXPANDED) {
      // 展开状态
      collapsingToolbarLayout.setTitle("");
      toolbar.setBackgroundColor(Color.TRANSPARENT);
      if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT && window != null) {
        window.setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS, WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
      }
    } else if (state == State.COLLAPSED) {
      // 折叠状态
    } else {
      // 中间状态
      collapsingToolbarLayout.setTitle(mediaName);
      toolbar.setBackgroundColor(SettingUtil.getInstance().getColor());
      if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT && window != null) {
        window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
      }
    }
  }
});

代码示例来源:origin: xinghongfei/LookLook

private void setStatusColor() {
  Bitmap bm = BitmapFactory.decodeResource(getResources(),
      R.drawable.nav_icon);
  Palette palette = Palette.generate(bm);
  if (palette.getLightVibrantSwatch() != null) {
    mainColor = palette.getLightVibrantSwatch().getRgb();
    getWindow().setStatusBarColor(palette.getLightVibrantSwatch().getRgb());
    toolbar.setBackgroundColor(palette.getLightVibrantSwatch().getRgb());
  }
}

代码示例来源:origin: wangdan/AisenWeiBo

@Override
protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.ui_pictures);
  
  getSupportActionBar().setDisplayShowHomeEnabled(false);
  getSupportActionBar().setDisplayHomeAsUpEnabled(true);
  mBean = savedInstanceState == null ? (StatusContent) getIntent().getSerializableExtra("bean")
                    : (StatusContent) savedInstanceState.getSerializable("bean");
  index = savedInstanceState == null ? getIntent().getIntExtra("index", 0)
                  : savedInstanceState.getInt("index", 0);
  myViewPagerAdapter = new MyViewPagerAdapter(getFragmentManager());
  viewPager.setAdapter(myViewPagerAdapter);
  viewPager.setOnPageChangeListener(this);
  viewPager.setCurrentItem(index);
  if (size() > 1 && getSupportActionBar() != null)
    getSupportActionBar().setTitle(String.format("%d/%d", index + 1, size()));
  else if (getSupportActionBar() != null)
    getSupportActionBar().setTitle(String.format("%d/%d", 1, 1));
  getToolbar().setBackgroundColor(Color.TRANSPARENT);
  if (Build.VERSION.SDK_INT >= 19) {
    layToolbar.setPadding(layToolbar.getPaddingLeft(),
                  layToolbar.getPaddingTop() + SystemUtils.getStatusBarHeight(this),
                  layToolbar.getPaddingRight(),
                  layToolbar.getPaddingBottom());
  }
}

代码示例来源:origin: iMeiji/Toutiao

@Override
protected void initView(View view) {
  super.initView(view);
  Toolbar toolbar = view.findViewById(R.id.toolbar);
  initToolBar(toolbar, true, getString(R.string.title_wenda));
  toolbar.setOnClickListener(view1 -> recyclerView.smoothScrollToPosition(0));
  toolbar.setBackgroundColor(SettingUtil.getInstance().getColor());
  adapter = new MultiTypeAdapter(oldItems);
  Register.registerWendaContentItem(adapter);
  recyclerView.setAdapter(adapter);
  recyclerView.addOnScrollListener(new OnLoadMoreListener() {
    @Override
    public void onLoadMore() {
      if (canLoadMore) {
        canLoadMore = false;
        presenter.doLoadMoreData();
      }
    }
  });
  setHasOptionsMenu(true);
}

代码示例来源:origin: scwang90/SmartRefreshLayout

toolbar.setBackgroundColor(0);

代码示例来源:origin: iMeiji/Toutiao

@Override
protected void initView(View view) {
  super.initView(view);
  Toolbar toolbar = view.findViewById(R.id.toolbar);
  initToolBar(toolbar, true, getString(R.string.title_comment));
  toolbar.setOnClickListener(view1 -> recyclerView.smoothScrollToPosition(0));
  toolbar.setBackgroundColor(SettingUtil.getInstance().getColor());
  adapter = new MultiTypeAdapter(oldItems);
  Register.registerNewsCommentItem(adapter);
  recyclerView.setAdapter(adapter);
  recyclerView.addOnScrollListener(new OnLoadMoreListener() {
    @Override
    public void onLoadMore() {
      if (canLoadMore) {
        canLoadMore = false;
        presenter.doLoadMoreData();
      }
    }
  });
  setHasOptionsMenu(true);
}

代码示例来源:origin: wangdan/AisenWeiBo

@Override
protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.ui_timeline_pic);
  getSupportActionBar().setDisplayShowHomeEnabled(false);
  getSupportActionBar().setDisplayHomeAsUpEnabled(true);
  getSupportActionBar().setTitle("");
  getToolbar().setBackgroundColor(Color.TRANSPARENT);
  if (Build.VERSION.SDK_INT >= 19) {
    layToolbar.setPadding(layToolbar.getPaddingLeft(),
        layToolbar.getPaddingTop() + SystemUtils.getStatusBarHeight(this),
        layToolbar.getPaddingRight(),
        layToolbar.getPaddingBottom());
  }
  if (savedInstanceState == null) {
    BizFragment.createBizFragment(this);
    mHandler.sendEmptyMessageDelayed(1, 200);
  }
  else {
    finish();
  }
}

代码示例来源:origin: bingoogolapple/BGASwipeBackLayout-Android

@Override
  public void onGenerated(Palette palette) {
    Palette.Swatch vibrant = palette.getVibrantSwatch();
    mTabLayout.setBackgroundColor(vibrant.getRgb());
    mTabLayout.setSelectedTabIndicatorColor(colorBurn(vibrant.getRgb()));
    mTabLayout.setSelectedTabIndicatorColor(colorBurn(vibrant.getRgb()));
    mToolbar.setBackgroundColor(vibrant.getRgb());
    setStatusBarColor(colorBurn(vibrant.getRgb()));
  }
});

相关文章

Toolbar类方法