M
M
Masteron2016-02-25 12:19:37
Android
Masteron, 2016-02-25 12:19:37

Toolbar how to arrange items?

There is this menu:

<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto">
    <item
        android:id="@+id/navigation_bar"
        android:title="@string/navigation"
        android:orderInCategory="100"

        app:showAsAction="ifRoom"
        android:icon="@drawable/is_back">
    </item>
</menu>

How to place this item in a certain place (for example, in the left corner of the toolbar)?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
L
LeEnot, 2016-02-25
@LeEnot

1. This is the standard way, it will only position the elements in the standard way, i.e. just how Google intended
2. To arrange custom elements, you need to re-layout the Toolbar itself like this
3. Since this is extremely against Google's guidelines, consider whether this is really what you need

E
Elysey, 2016-02-25
@Elysey

Alternatively, you can write the following lines in the Activity:

setSupportActionBar((Toolbar) findViewById(R.id.toolbar));        
getSupportActionBar().setDisplayHomeAsUpEnabled(true);       
getSupportActionBar().setHomeAsUpIndicator(R.drawable. is_back);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question