Android examples for android.app:Toolbar
setup Toolbar No Title
import android.app.Activity; import android.support.annotation.IdRes; import android.support.annotation.LayoutRes; import android.support.v7.app.ActionBar; import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.Toolbar; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.TextView; public class Main{ public static Toolbar setupToolbarNoTitle(AppCompatActivity activity, @IdRes int toolbarResId) { ActionBar ab = activity.getSupportActionBar(); if (ab != null) throw new IllegalStateException( "Activity already has a toolbar"); Toolbar layoutToolbar = (Toolbar) activity .findViewById(toolbarResId); Toolbar result = (Toolbar) activity .findViewById(R.id.tablet_toolbar); if (result != null) { if (layoutToolbar != null) { layoutToolbar.setVisibility(View.GONE); }// www. jav a 2 s.c o m activity.setSupportActionBar(result); ((TextView) activity.findViewById(R.id.toolbar_title)) .setText(activity.getTitle()); activity.getSupportActionBar().setTitle(null); return result; } activity.setSupportActionBar(layoutToolbar); activity.getSupportActionBar().setTitle(null); return layoutToolbar; } }