0

I've tried quite a bit messing around with the ActionBarDrawerToggle & the Styles.xml with themes but nothing that I've tried or out there on Google & Stack seems to be what I need.

I'm using the v7 ActionBarDrawerToggle.

As the title says, what exactly I need to do is to keep everything as it is as on the drawer except for the Arrow when the drawer is open & when it is closed when an item is selected.

I want that arrow gone & the hamburger icon to stay. I can achieve this easily but not without losing the animation. Which is the other thing, I want too keep the animation as well, so instead of the hamburger animating/spinning to an arrow, the hamburger will animate/spin to another hamburger.

Any ideas?

Thanks! Cheers!

Here's the code

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_ACTION_BAR);
    setContentView(R.layout.activity_main);

    getActionBar().setBackgroundDrawable(new
                  ColorDrawable(Color.parseColor("#CC0000")));

    getActionBar().setDisplayHomeAsUpEnabled(true);
    getActionBar().setHomeButtonEnabled(true);

    linearMain = (LinearLayout) findViewById(R.id.linearMain);

    mDrawerLayout = (DrawerLayout) findViewById(R.id.layout_mainactivity);
    mDrawerList = (ListView) findViewById(R.id.left_drawer);
    mDrawerList.setDividerHeight(1);

    mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout,
    R.drawable.ic_drawer, R.string.drawer_open) {
    };

    mDrawerLayout.setDrawerListener(mDrawerToggle);

    mDrawerList.setAdapter(new ArrayAdapter<String>(this,
            R.layout.drawer_list_item, menuItems));

    Fragment fragment = null;

    Class<TabLayoutFragment> fragmentClass = TabLayoutFragment.class;
    try {
        fragment = (Fragment) fragmentClass.newInstance();
    } catch (Exception e) {
        e.printStackTrace();
    }

    FragmentManager fragmentManager = getSupportFragmentManager();
    FragmentTransaction fragmentTransaction =
    fragmentManager.beginTransaction();
    fragmentTransaction.replace(R.id.fragmentContainer, fragment);
    fragmentTransaction.commit();

    mDrawerList.setOnItemClickListener(new OnItemClickListener(){
    @Override
    public void onItemClick(AdapterView<?> parent, View view, final int
    pos,long id){
          mDrawerLayout.setDrawerListener( new
                        DrawerLayout.SimpleDrawerListener(){
                @Override
                public void onDrawerClosed(View drawerView){
                    super.onDrawerClosed(drawerView);
                    if (pos == 0){
                     TabLayoutFragment.tabLayoutViewPager.setCurrentItem(0);
                    } else if (pos == 1) {
                     TabLayoutFragment.tabLayoutViewPager.setCurrentItem(1);
                    }           
                }
            });
            mDrawerLayout.closeDrawer(linearMain); 
        }
    });
}

@Override
protected void onPostCreate(Bundle savedInstanceState) {
    super.onPostCreate(savedInstanceState);
    mDrawerToggle.syncState();
}

@Override
public void onConfigurationChanged(Configuration newConfig) {
    super.onConfigurationChanged(newConfig);
    mDrawerToggle.onConfigurationChanged(newConfig);
}
Jay Gunawardena
  • 65
  • 2
  • 12
  • Changing that animation might be a little tricky. Check out the [`DrawerArrowDrawable` class](http://grepcode.com/file/repository.grepcode.com/java/ext/com.google.android/android/5.0.1_r1/android/support/v7/app/DrawerArrowDrawable.java), particularly the `draw()` method. – Mike M. Oct 11 '15 at 10:28
  • It may be that the only way to change it is to set your own drawable and manually handle the animation when the drawer is expanding/closing – Marcus Hooper Oct 11 '15 at 10:44
  • Well, that'll be a pain to implement :( & thanks Mike, looking into that doesn't really help though I suppose. – Jay Gunawardena Oct 11 '15 at 11:08

0 Answers0