Java Code Examples for android.support.v7.widget.Toolbar#getTitle()
The following examples show how to use
android.support.v7.widget.Toolbar#getTitle() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CalligraphyFactory.java From Calligraphy with Apache License 2.0 | 6 votes |
/** * 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); }
Example 2
Source File: BaseActivity.java From Learning-Resources with MIT License | 5 votes |
/** * Center the Toolbar Title. * * @param toolbar */ protected void centerTitle(Toolbar toolbar) { final CharSequence originalTitle = toolbar.getTitle(); TextView mTitle = toolbar.findViewById(R.id.toolbarTitle); mTitle.setText(originalTitle); getSupportActionBar().setDisplayShowTitleEnabled(false); toolbar.setTitle(""); }