What is the difference between a toolbar and another view?

3

I'm learning how to use toolbar in Android development and I've seen that using it is very similar to other views , I saw that you can put it without being at the top, that you can put items inside it. example), type a layout, then hit the doubt, can I use a LinearLayout (or other) as a toolbar ? Put it on the top, set the colors, put items, etc ... What are the benefits of using the same toolbar?

    
asked by anonymous 20.10.2017 / 06:28

1 answer

3

Toolbar is actually a type of View, rather a type of ViewGroup:

java.lang.Object
   ↳    android.view.View
       ↳    android.view.ViewGroup
           ↳    android.support.v7.widget.Toolbar 

As you can see in your hierarchy, it inherits the characteristics of View and ViewGroup. That is why it is possible to do everything that you list in the question.

However, Toolbar is much more than a ViewGroup. It adds other features in order to be a alternative to ActionBar .

Among them,

  • Navigation button.
  • Logo.
  • Title and subtitle.
  • Include other views.
  • Actions menu.
20.10.2017 / 15:06