1

ActionBar

ActionBar was launched by android 3.0. At that time, Google wanted to gradually improve the messy interface design of android in the past, hoping to allow end users to have a consistent operating experience on android phones as much as possible. The two most popular packages for ActionBar in the past are ActionBarSherlock and AppCompat, which is officially provided in the support library v 7.

The Action bar is included in all activities (or subclasses of these activities) that use the Theme.Hole theme.

delete actionbar

If you don't want to use ActionBar, just add ".NoActionBar" after the theme, and it will work.

Since I don’t use it much now, I just passed it.

Toolbar

The Toolbar was launched by android 5.0 and was placed in the v7 package as a control. It was created to replace the actionbar, which means that the official believes that the ActionBar limits the flexibility of the development and design of the android app to a certain extent, and in the material design also defines its name: App bar.

simple to use

layout

<android.support.v7.widget.Toolbar    
    android:id="@+id/toolbar"    
    android:layout_width="match_parent"    
    android:layout_height="?attr/actionBarSize"    
    android:background="?attr/colorPrimary"    
    app:popupTheme="@style/ThemeOverlay.AppCompat.Light"    
    app:layout_scrollFlags="scroll|enterAlways"/>

Code

Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);

SetSupportActionBar, Toolbar can replace the original actionbar

Screenshot to illustrate:

toolbar.png

For other detailed usage, you can see the recommended article below, which has been written very well:

android: ToolBar detailed explanation (

source
Author: 666swb
Link: https://www.jianshu.com/p/733dacbd8135
Source: Brief Book
The copyright belongs to the author. For commercial reprints, please contact the author for authorization, and for non-commercial reprints, please indicate the source.

Adam
63 声望6 粉丝

hello world