本文整理了Java中android.support.v7.widget.Toolbar.getContext()
方法的一些代码示例,展示了Toolbar.getContext()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Toolbar.getContext()
方法的具体详情如下:
包路径:android.support.v7.widget.Toolbar
类名称:Toolbar
方法名:getContext
暂无
代码示例来源:origin: florent37/MaterialViewPager
private MaterialViewPagerHeader(Toolbar toolbar) {
this.toolbar = toolbar;
this.context = toolbar.getContext();
this.toolbarLayout = (View) toolbar.getParent();
}
代码示例来源:origin: rey5137/material
private ToolbarRippleDrawable getBackground(){
if(mBuilder == null)
mBuilder = new ToolbarRippleDrawable.Builder(mToolbar.getContext(), mRippleStyle);
return mBuilder.build();
}
代码示例来源:origin: rey5137/material
super(new NavigationDrawerDrawable.Builder(toolbar.getContext(), styleId).build(), toolbar);
mDrawerLayout = drawerLayout;
mFragmentManager = fragmentManager;
代码示例来源:origin: rey5137/material
@Override
public void onThemeChanged(@Nullable ThemeManager.OnThemeChangedEvent event) {
int style = ThemeManager.getInstance().getCurrentStyle(mStyleId);
if(mCurrentStyle != style){
mCurrentStyle = style;
NavigationDrawerDrawable drawable = new NavigationDrawerDrawable.Builder(mToolbar.getContext(), mCurrentStyle).build();
drawable.switchIconState(mNavigationIcon.getIconState(), false);
mNavigationIcon = drawable;
mToolbar.setNavigationIcon(mNavigationVisible ? mNavigationIcon : null);
}
}
代码示例来源:origin: chrisjenx/Calligraphy
/**
* Will forcibly set text on the views then remove ones that didn't have copy.
*
* @param view toolbar view.
*/
private void applyFontToToolbar(final Toolbar view) {
final CharSequence previousTitle = view.getTitle();
final CharSequence previousSubtitle = view.getSubtitle();
// The toolbar inflates both the title and the subtitle views lazily but luckily they do it
// synchronously when you set a title and a subtitle programmatically.
// So we set a title and a subtitle to something, then get the views, then revert.
view.setTitle("uk.co.chrisjenx.calligraphy:toolbar_title");
view.setSubtitle("uk.co.chrisjenx.calligraphy:toolbar_subtitle");
// Iterate through the children to run post inflation on them
final int childCount = view.getChildCount();
for (int i = 0; i < childCount; i++) {
onViewCreated(view.getChildAt(i), view.getContext(), null);
}
// Remove views from view if they didn't have copy set.
view.setTitle(previousTitle);
view.setSubtitle(previousSubtitle);
}
}
代码示例来源:origin: code-mc/material-icon-lib
MaterialMenuInflater.with(toolbar1.getContext(), new SupportMenuInflater(toolbar1.getContext()))
.inflate(R.menu.menu_nocolor, toolbar1.getMenu());
代码示例来源:origin: eneim/toro
private void setupDemoButton() {
View buttonContainer = toolbar.findViewById(R.id.home_toolbar_button);
if (buttonContainer == null) {
buttonContainer = LayoutInflater.from(toolbar.getContext())
.inflate(R.layout.widget_toolbar_button, toolbar, false);
buttonContainer.setId(R.id.home_toolbar_button);
ActionBar.LayoutParams params = (ActionBar.LayoutParams) buttonContainer.getLayoutParams();
params.gravity = GravityCompat.END;
toolbar.addView(buttonContainer, params);
}
buttonContainer.findViewById(R.id.button_open_demos)
.setOnClickListener(__ -> startActivity(new Intent(this, MainActivity.class)));
}
代码示例来源:origin: OceanLabs/Android-Print-SDK
@Override
public Context getActionBarThemedContext()
{
return mToolbar.getContext();
}
代码示例来源:origin: zhuanghongji/mp-android-chart
@Override
public void onClick(View view) {
((Activity)(toolbar.getContext())).finish();
}
});
代码示例来源:origin: franmontiel/FullScreenDialog
private void tintToolbarButton(Toolbar toolbar, Drawable buttonDrawable) {
int[] colorAttrs = new int[]{R.attr.colorControlNormal};
TypedArray a = toolbar.getContext().obtainStyledAttributes(colorAttrs);
int color = a.getColor(0, -1);
a.recycle();
DrawableCompat.setTint(DrawableCompat.wrap(buttonDrawable), color);
}
代码示例来源:origin: consp1racy/android-support-preference
@NonNull
@Override
public View makeView() {
TextView tv = new AppCompatTextView(mToolbar.getContext());
//noinspection deprecation
tv.setTextAppearance(tv.getContext(), R.style.TextAppearance_AppCompat_Widget_ActionBar_Title);
return tv;
}
});
代码示例来源:origin: yanzhenjie/mvp-sample
@Override
MenuInflater getMenuInflater() {
return new SupportMenuInflater(mActionBar != null ? mActionBar.getContext() : getContext());
}
代码示例来源:origin: yanzhenjie/mvp-sample
@Override
MenuInflater getMenuInflater() {
return new SupportMenuInflater(mActionBar != null ? mActionBar.getContext() : getContext());
}
代码示例来源:origin: WangDaYeeeeee/Mysplash
public static void setNavigationIcon(Toolbar toolbar,
@DrawableRes int lightResId, @DrawableRes int darkResId) {
if (getInstance(toolbar.getContext()).isLightTheme()) {
toolbar.setNavigationIcon(lightResId);
} else {
toolbar.setNavigationIcon(darkResId);
}
}
代码示例来源:origin: kollerlukas/Camera-Roll-Android-App
@SuppressWarnings("inlineValue")
public static TextView setToolbarTypeface(Toolbar toolbar) {
for (int i = 0; i < toolbar.getChildCount(); i++) {
View view = toolbar.getChildAt(i);
if (view instanceof TextView) {
TextView textView = (TextView) view;
if (textView.getText().equals(toolbar.getTitle())) {
Typeface typeface = ResourcesCompat
.getFont(toolbar.getContext(), R.font.roboto_mono_medium);
textView.setTypeface(typeface);
return textView;
}
}
}
return null;
}
代码示例来源:origin: adgvcxz/Dribbble-MVVM
@BindingAdapter({"backPaletteUrl", "navigationOnClickListener"})
public static void setBackPaletteIcon(Toolbar toolbar, String url, View.OnClickListener listener) {
Observable.just(url).filter(s -> !TextUtils.isEmpty(url))
.flatMap(s -> {
if (Util.isImageDownloaded(toolbar.getContext(), Uri.parse(s))) {
return Observable.just(BitmapFactory.decodeFile(Util.getCachedImageOnDisk(toolbar.getContext(), Uri.parse(url)).getAbsolutePath()))
.flatMap(bitmap -> RxUtil.toObservablePalette(bitmap, Color.parseColor("#424242")));
}
return Observable.just(Color.parseColor("#424242"));
}).subscribeOn(Schedulers.io())
.map(integer -> {
Drawable drawable = ContextCompat.getDrawable(toolbar.getContext(), R.mipmap.ic_back_arrow);
drawable.setColorFilter(integer, PorterDuff.Mode.SRC_ATOP);
return drawable;
}).map(drawable -> {
toolbar.post(() -> toolbar.setNavigationIcon(drawable));
return toolbar.getContext();
}).delay(300, TimeUnit.MILLISECONDS).observeOn(AndroidSchedulers.mainThread())
.subscribe(context -> {
ViewCompat.animate(toolbar).alpha(1f).setDuration(200).start();
toolbar.setNavigationOnClickListener(listener);
});
}
}
代码示例来源:origin: Phantast/smartnavi
public void handleMessage(Message msg) {
if (msg.what == 0) {
mSuggestionsAdapter = new SuggestionsAdapter(toolbar.getContext(), cursor);
searchView.setSuggestionsAdapter(GoogleMap.mSuggestionsAdapter);
// important to update suggestion list
searchView.getSuggestionsAdapter().notifyDataSetChanged();
suggestionsInProgress = false;
}
super.handleMessage(msg);
}
};
代码示例来源:origin: zendesk/belvedere
private void tintStatusBar(float scrollOffset) {
int colorPrimaryDark = Utils.getThemeColor(toolbar.getContext(), R.attr.colorPrimaryDark);
boolean fullyExpanded = scrollOffset == 1.f;
final Window window = activity.getWindow();
代码示例来源:origin: jeanboydev/Android-Architecture
/**
* 向上需要全部滚出屏幕时设置topMargin代替fitsSystemWindows="true"
*
* @param toolbar
*/
public static void setStatusBarFits(Toolbar toolbar) {
if (toolbar == null) return;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
if (toolbar.getLayoutParams() instanceof AppBarLayout.LayoutParams) {
AppBarLayout.LayoutParams params = (AppBarLayout.LayoutParams) toolbar.getLayoutParams();
params.topMargin = StatusBarUtil.getStatusBarHeight(toolbar.getContext());
toolbar.setLayoutParams(params);
hideNavigationBar((Activity) toolbar.getContext());
}
}
}
代码示例来源:origin: gigabytedevelopers/FireFiles
public void updateActionBar() {
final RootInfo root = getCurrentRoot();
mToolbar.setNavigationIcon(
root != null ? root.loadToolbarIcon(mToolbar.getContext()) : null);
mToolbar.setNavigationContentDescription(R.string.drawer_open);
mToolbar.setNavigationOnClickListener(null);
if (mSearchExpanded) {
mToolbar.setTitle(null);
mToolbarStack.setVisibility(View.GONE);
mToolbarStack.setAdapter(null);
} else {
if (mState.stack.size() <= 1) {
mToolbar.setTitle(root.title);
mToolbarStack.setVisibility(View.GONE);
mToolbarStack.setAdapter(null);
} else {
mToolbar.setTitle(null);
mToolbarStack.setVisibility(View.VISIBLE);
mToolbarStack.setAdapter(mStackAdapter);
mIgnoreNextNavigation = true;
mToolbarStack.setSelection(mStackAdapter.getCount() - 1);
}
}
}
@Override
内容来源于网络,如有侵权,请联系作者删除!