本文整理了Java中android.support.v7.widget.Toolbar
类的一些代码示例,展示了Toolbar
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Toolbar
类的具体详情如下:
包路径:android.support.v7.widget.Toolbar
类名称:Toolbar
暂无
代码示例来源:origin: smuyyh/BookReader
@Override
public void initToolBar() {
mCommonToolbar.setTitle("设置");
mCommonToolbar.setNavigationIcon(R.drawable.ab_back);
}
代码示例来源:origin: HotBitmapGG/bilibili-android-client
@Override
public void initToolBar() {
mToolbar.setNavigationIcon(R.drawable.ic_cancle);
mToolbar.setTitle("登录");
mToolbar.setNavigationOnClickListener(v -> finish());
}
代码示例来源:origin: TeamNewPipe/NewPipe
private void initToolbar(Toolbar toolbar) {
if (DEBUG) Log.d(TAG, "initToolbar() called with: toolbar = [" + toolbar + "]");
toolbar.setTitle(R.string.download_dialog_title);
toolbar.setNavigationIcon(ThemeHelper.isLightThemeSelected(getActivity()) ? R.drawable.ic_arrow_back_black_24dp : R.drawable.ic_arrow_back_white_24dp);
toolbar.inflateMenu(R.menu.dialog_url);
toolbar.setNavigationOnClickListener(v -> getDialog().dismiss());
toolbar.setOnMenuItemClickListener(item -> {
if (item.getItemId() == R.id.okay) {
prepareSelectedDownload();
return true;
}
return false;
});
}
代码示例来源:origin: chrisjenx/Calligraphy
@Override public void run() {
toolbar.setTitle(null);
toolbar.setSubtitle("Added subtitle");
}
}, 2000);
代码示例来源:origin: rey5137/material
public NavigationManager(NavigationDrawerDrawable navigationIcon, Toolbar toolbar){
mToolbar = toolbar;
mNavigationIcon = navigationIcon;
mToolbar.setNavigationIcon(mNavigationVisible ? mNavigationIcon : null);
mToolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
onNavigationClick();
}
});
mAnimationDuration = toolbar.getResources().getInteger(android.R.integer.config_shortAnimTime);
}
代码示例来源:origin: seven332/EhViewer
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
if (mToolbar != null) {
if (mTempTitle != null) {
mToolbar.setTitle(mTempTitle);
mTempTitle = null;
}
int menuResId = getMenuResId();
if (menuResId != 0) {
mToolbar.inflateMenu(menuResId);
mToolbar.setOnMenuItemClickListener(new Toolbar.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
return ToolbarScene.this.onMenuItemClick(item);
}
});
onMenuCreated(mToolbar.getMenu());
}
mToolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
onNavigationClick();
}
});
}
}
代码示例来源:origin: Cleveroad/AdaptiveTableLayout
toolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
toolbar.inflateMenu(R.menu.table_layout);
toolbar.setOnMenuItemClickListener(new Toolbar.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
代码示例来源:origin: seven332/EhViewer
toolbar.setTitle(R.string.download_labels);
toolbar.inflateMenu(R.menu.drawer_download);
toolbar.setOnMenuItemClickListener(new Toolbar.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
代码示例来源:origin: TakWolf/CNode-Material-Design
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
ThemeUtils.configThemeBeforeOnCreate(this, R.style.AppThemeLight, R.style.AppThemeDark);
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_notification_compat);
ButterKnife.bind(this);
toolbar.setNavigationOnClickListener(new NavigationFinishClickListener(this));
toolbar.inflateMenu(R.menu.notification);
toolbar.setOnMenuItemClickListener(this);
toolbar.setOnClickListener(new DoubleClickBackToContentTopListener(webNotification));
notificationPresenter = new NotificationPresenter(this, this);
refreshLayout.setColorSchemeResources(R.color.color_accent);
refreshLayout.setOnRefreshListener(this);
refreshLayout.setRefreshing(true);
onRefresh();
}
代码示例来源:origin: jaydenxiao2016/AndroidFire
private void initToolbar() {
toolbar.setTitle(getString(R.string.girl));
toolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
finish();
}
});
}
代码示例来源:origin: liuguangqiang/SwipeBack
private void initViews() {
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
toolbar.setTitle(R.string.title_activity_viewpager);
toolbar.setTitleTextColor(Color.WHITE);
setSupportActionBar(toolbar);
ViewPager viewPager = (ViewPager) findViewById(R.id.viewpager_demo);
TestAdapter adapter = new TestAdapter(getSupportFragmentManager());
viewPager.setAdapter(adapter);
}
代码示例来源:origin: aa112901/remusic
private void setupToolbar() {
setSupportActionBar(toolbar);
final ActionBar ab = getSupportActionBar();
ab.setHomeAsUpIndicator(R.drawable.actionbar_back);
ab.setDisplayHomeAsUpEnabled(true);
ab.setTitle("歌单");
toolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
onBackPressed();
}
});
//collapsingToolbarLayout.setTitle("歌单");
}
代码示例来源:origin: omadahealth/LolliPin
private void initView() {
Toolbar toolbar = (Toolbar) findViewById(R.id.id_toolbar);
setSupportActionBar(toolbar);
toolbar.setTitle("Title");
toolbar.setTitleTextColor(getResources().getColor(android.R.color.white));
toolbar.setSubtitle("SubTitle");
toolbar.setSubtitleTextColor(getResources().getColor(android.R.color.white));
toolbar.setLogo(R.drawable.ic_launcher);
toolbar.setNavigationIcon(R.drawable.ic_menu_white_36dp);
}
}
代码示例来源:origin: qiujuer/Genius-Android
private void initToolbar() {
// ToolBar
RipAnimDrawable ripAnim = new RipAnimDrawable();
ripAnim.setColor(getResources().getColor(R.color.cyan_600));
ripAnim.setFluCount(0, 0, 0, 36);
Toolbar toolbar = (Toolbar) findViewById(R.id.title);
toolbar.setBackgroundDrawable(ripAnim);
toolbar.setTitle(getTitle());
toolbar.inflateMenu(R.menu.menu_main);
toolbar.setOnMenuItemClickListener(this);
}
代码示例来源:origin: yanzhenjie/NoHttp
@Override
void setActionBar(Toolbar actionBar) {
this.mActionBar = actionBar;
if (mActionBar != null) {
mActionBar.setOnMenuItemClickListener(new Toolbar.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
if (mMenuItemSelectedListener != null) {
mMenuItemSelectedListener.onMenuClick(item);
}
return true;
}
});
mActionBar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (mMenuItemSelectedListener != null) {
mMenuItemSelectedListener.onHomeClick();
}
}
});
mActionBarIcon = mActionBar.getNavigationIcon();
}
}
代码示例来源:origin: mxn21/FlowingDrawer
protected void setupToolbar() {
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
toolbar.setNavigationIcon(R.drawable.ic_menu_white);
toolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mDrawer.toggleMenu();
}
});
}
代码示例来源:origin: HotBitmapGG/bilibili-android-client
@Override
public void initToolBar() {
mToolbar.setTitle("番剧详情");
setSupportActionBar(mToolbar);
ActionBar supportActionBar = getSupportActionBar();
mToolbar.setBackgroundColor(Color.argb(0, 251, 114, 153));
代码示例来源: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: aa112901/remusic
private void setupToolbar() {
setSupportActionBar(toolbar);
actionBar = getSupportActionBar();
actionBar.setHomeAsUpIndicator(R.drawable.actionbar_back);
actionBar.setDisplayHomeAsUpEnabled(true);
actionBar.setTitle("歌单");
toolbar.setPadding(0, mStatusSize, 0, 0);
toolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
onBackPressed();
}
});
toolbar.setSubtitle(albumDes);
}
代码示例来源: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;
}
});
内容来源于网络,如有侵权,请联系作者删除!