Tell me how to work with the upper header (column) of the application (where the name is), using the form (template) EmptyActivity.

How to add something there, how to change?

    1 answer 1

    This part of the interface is called App Bar. As the App Bar, you can use either Action Bar or Toolbar.

    Toolbar has replaced Action Bar, as a more flexible tool for creating an App Bar.

    Implement the Toolbar in the application as follows:

    1. Inherit activations from AppCompatActivity :

       public class MyActivity extends AppCompatActivity { // ... } 
    2. Set an application theme that does not contain an Action Bar:

       <application android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> 
    3. Mark the toolbar in the markup file:

       <android.support.v7.widget.Toolbar android:id="@+id/my_toolbar" android:layout_width="match_parent" android:layout_height="?attr/actionBarSize" android:background="?attr/colorPrimary" android:elevation="4dp" android:theme="@style/ThemeOverlay.AppCompat.ActionBar" app:popupTheme="@style/ThemeOverlay.AppCompat.Light"/> 
    4. Install Toolbar as an App Bar:

       private Toolbar mToolbar; ... @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_my); mToolbar = (Toolbar) findViewById(R.id.my_toolbar); setSupportActionBar(myToolbar); } 

    How to work with the Toolbar is a rather voluminous question, so I’ll bring only the main points:

    1. Setting the title:

       getSupportActionBar().setTitle("Title"); 
    2. Enabling the reverse navigation feature:

       getSupportActionBar().setDisplayHomeAsUpEnabled(true); 
    3. Set Icon:

       getSupportActionBar().setIcon(R.mipmap.ic_launcher); 

    More information can be found in the official documentation at the following link: Adding the App Bar .

    • that is, to create a form not "emptiktiviti" but empty and put a toolbar there? just just started to learn the program. I can't even find the information - Max
    • @ Max, Empty Activity - this is an empty template. - post_zeew