1

This my toolbar:

<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.Toolbar  xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_height="60dp"
    android:layout_width="match_parent"
    android:minHeight="?attr/actionBarSize"
    android:background="#2c3039"
    android:id="@+id/toolbar" >

    //some code here 

</android.support.v7.widget.Toolbar>

This the drawer code:

mToolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(mToolbar);
getSupportActionBar().setDisplayShowHomeEnabled(true);

mDrawerToggle = new ActionBarDrawerToggle(getActivity(), drawerLayout, toolbar, R.string.drawer_open, R.string.drawer_close) {
    @Override
    public void onDrawerOpened(View drawerView) {
        super.onDrawerOpened(drawerView);
        getActivity().invalidateOptionsMenu();
    }

    @Override
    public void onDrawerClosed(View drawerView) {
        super.onDrawerClosed(drawerView);
        getActivity().invalidateOptionsMenu();
    }

    @Override
    public void onDrawerSlide(View drawerView, float slideOffset) {
        super.onDrawerSlide(drawerView, slideOffset);
        toolbar.setAlpha(1 - slideOffset / 2);
    }
};

mDrawerLayout.setDrawerListener(mDrawerToggle);
mDrawerLayout.post(new Runnable() {
    @Override
    public void run() {
        mDrawerToggle.syncState();
    }
});

toolbar.setNavigationOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
        if (mDrawerLayout.isDrawerOpen(Gravity.RIGHT)) {
             mDrawerLayout.closeDrawer(Gravity.RIGHT);
        } else {
             mDrawerLayout.openDrawer(Gravity.RIGHT);
        }
    }
});

Now the drawer open from right to left only have one problem its how can I change the alignment for icon to right too? And change its color to white?

Here's my current drawer: My Drawer

Ravers
  • 988
  • 2
  • 14
  • 45
medo
  • 23
  • 6
  • Possible duplicate of [Android navigation drawer toggle icon to right](http://stackoverflow.com/questions/39132398/android-navigation-drawer-toggle-icon-to-right) – Mike M. Oct 12 '16 at 22:32
  • I'm not sure which part you want white, but you can use `toggleButton.setBackgroundColor()` and/or `arrowDrawable.setColor()` in `EndDrawerToggle` to set whichever you want. – Mike M. Oct 12 '16 at 22:32

1 Answers1

1

use layoutDirection whit rtl value:

android:layoutDirection="rtl"

if it doesn't work use :

android:layout_gravity="right"

and in your DrawerLayout :

tools:openDrawer="right"

maybe its better to change your layout like this:

<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true"
    android:layoutDirection="rtl"
    tools:context=".activities.MainActivity">

    <android.support.design.widget.AppBarLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:theme="@style/AppTheme.AppBarOverlay"
        app:elevation="0dp" >

        <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/AppTheme.PopupOverlay" />

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


</android.support.design.widget.CoordinatorLayout>
mohammadreza khalifeh
  • 1,510
  • 2
  • 18
  • 32