Adding custom view to a toolbar
Works great for me.
LayoutInflater mInflater=LayoutInflater.from(context);
View mCustomView = mInflater.inflate(R.layout.toolbar_custom_view, null);
toolbar.addView(mCustomView);
Just inflate the view that you want to add passing the toolbar view as second parameter of the inflate method; In this way the call to "addView" is not necessary:
setSupportActionBar(toolbar);
View logo = getLayoutInflater().inflate(R.layout.view_logo, toolbar);
With toolbar I've managed to achieve that like this:
setSupportActionBar(toolbar);
View logo = getLayoutInflater().inflate(R.layout.view_logo, null);
toolbar.addView(logo);
Or you can also just add your view to the toolbar xml, as it's just a ViewGroup. This way you'll have the preview in layout editor. No java code required.