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?
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:
Inherit activations from AppCompatActivity :
public class MyActivity extends AppCompatActivity { // ... } Set an application theme that does not contain an Action Bar:
<application android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> 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"/> 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:
Setting the title:
getSupportActionBar().setTitle("Title"); Enabling the reverse navigation feature:
getSupportActionBar().setDisplayHomeAsUpEnabled(true); 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 .
Source: https://ru.stackoverflow.com/questions/604754/
All Articles