Thank you for your question, its answer and, moreover, for the implementation of the toolbar in native and supportlibrary :)
And we can play more. We can play at runtime with height and minimum weight.
Height - ToolBar height, it is simple, every body understands, and gravity acts in accordance with this height.
The minimum height is more complex and should not be less than 56dp. This minHeight is used to place your menu bar. This line is in the middle of your minHeight.
So, you can add this code to your activity to see the difference. :)
Runnable toolBarAnimator=new Runnable() { @Override public void run() { if(postICS){ // toolbar.setTranslationX(iteration); // toolbar.setElevation(iteration); toolbar.setMinimumHeight(iteration * 5); toolbar.getLayoutParams().height++; } uiThreadHanlder.postDelayed(this,16); iteration++; if(iteration>150)iteration=0; } }; Handler uiThreadHanlder=new Handler(); int iteration=0; @Override protected void onResume() { super.onResume(); //launch the animation uiThreadHanlder.postDelayed(toolBarAnimator, 1000); } @Override protected void onPause() { super.onPause(); //stop the animation uiThreadHanlder.removeCallbacks(toolBarAnimator); }
Where is the toolbar:
toolbar = (toolbar) findViewById (R.id.toolbar);
In doing so, you get: 
but if you leave the animation you will get: 
This is why customizing your toolbar android: layout_height for wrap_content is a good option in most cases, because the toolbar will adapt its height to fit its contents (and you can change the contents at runtime :)
And this is also how you resize the toolbar at runtime.
Thanks to Chris Banes for the amazing work you did on the action bar.
Mathias Seguy Android2ee May 28 '15 at 15:10 2015-05-28 15:10
source share