0

I have a toolbar with navigation drawer. I want to do a toolbar with navigation bar same as in the picture.

enter image description here I have several problems with that:
1) Three dots appear instead of button icon.
2) The button title appears only when I click on these three dots (like a dropdown list).

enter image description here

I tried a lot of examples with ToolBar but still haven't get success. Maybe it is caused by DrawerLayout... Maybe anyone know what it is caused by?

Main activity:

public class CourierActivity extends AppCompatActivity {
    private ActionBarDrawerToggle mToggle;
    private DrawerLayout mDrawerLayout;
    private NavigationView nv;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
        setContentView(R.layout.courier_main);

        mDrawerLayout = (DrawerLayout) findViewById(R.id.drawerLayout);
        mToggle = new ActionBarDrawerToggle(this, mDrawerLayout, R.string.menu_open, R.string.menu_close);
        mDrawerLayout.addDrawerListener(mToggle);
        mToggle.syncState();

        getSupportActionBar().setDisplayHomeAsUpEnabled(true);

        NavigationView nv = (NavigationView) findViewById(R.id.navmenu);
        nv.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() {
            @Override
            public boolean onNavigationItemSelected(MenuItem menuItem) {
                switch (menuItem.getItemId()) {
                    // ...
                }

                return true;
            }
        });

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        MenuInflater me = getMenuInflater();
        me.inflate(R.menu.actionbar, menu);

        return super.onCreateOptionsMenu(menu);
    }
}

@menu/actionbar:

<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:tools="http://schemas.android.com/tools"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:android="http://schemas.android.com/apk/res/android">

    <item android:title="Item"
        android:id="@+id/refresh"
        android:icon="@android:drawable/bottom_bar"
        android:showAsAction="ifRoom"
        android:visible="true" />
</menu>

@layout/main_layout:

<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    tools:context="com.example.seether.myapplication.CourierActivity"
    android:background="#fff"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:id="@+id/drawerLayout">


    <android.support.design.widget.NavigationView
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        app:menu="@menu/navigation_menu"
        android:layout_gravity="start"
        app:headerLayout="@layout/navigation_layout"
        android:id="@+id/navmenu">

    </android.support.design.widget.NavigationView>


</android.support.v4.widget.DrawerLayout>

@menu/navigation_menu:

<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">

    <item
        android:id="@+id/orders"
        android:icon="@mipmap/ic_event_black_24dp"
        android:title="@string/orders" />

    <item
        android:id="@+id/settings"
        android:icon="@mipmap/ic_settings_black_24dp"
        android:title="@string/settings" />

    <item
        android:id="@+id/logout"
        android:icon="@mipmap/ic_exit_to_app_black_24dp"
        android:title="@string/logout" />

</menu>
Phantômaxx
  • 37,352
  • 21
  • 80
  • 110
phen0menon
  • 2,129
  • 2
  • 16
  • 36

0 Answers0