0

I want to keep the ActionBarDrawerToggle icon(hamburger) to the edge of the screen.

But by default it gives some space from the edge.enter image description here

How to keeps the icon to the side of edge(basically no space).

Annada
  • 1,075
  • 1
  • 18
  • 21
  • Have you tried set padding? – madhan kumar Jul 12 '16 at 14:28
  • Honestly, that's going to look pretty ugly if you do that. However, if you _really_ want to, it is possible to get a reference to that `ImageButton`. With that, you could then change its left padding, x-coordinate, etc. Alternatively, you could create your own toggle in a `Toolbar`, and set it up however you want. – Mike M. Jul 12 '16 at 15:52
  • Hi Mike, Yes I understood it may looks ugly, but that's the requirement. Is it possible to get reference of the ActionBarDrawerToggle icon resource? – Annada Jul 14 '16 at 20:26

1 Answers1

0

Probably too late, but ...

Actually Mike answered already similar question here Get reference to drawer toggle in support actionbar

I just reused his code. After you added the ActionBarDrawerToggle and called syncState() on it

final Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
ActionBarDrawerToggle actionBarDrawerToggle = new ActionBarDrawerToggle(...);

//Setting the actionbarToggle to drawer layout
drawerLayout.setDrawerListener(actionBarDrawerToggle);

//calling sync state is necessay or else your hamburger icon wont show up
actionBarDrawerToggle.syncState();

you can iterate through children of the toolbar and then ...

for (int i = 0; i < toolbar.getChildCount(); i++) {
    if(toolbar.getChildAt(i) instanceof ImageButton) {
        ImageButton imageButton = (ImageButton) toolbar.getChildAt(i);
        imageButton.setPadding(50, 100, 50, 50);
    }
}

Hopefully it helps

Community
  • 1
  • 1
Tima
  • 12,765
  • 23
  • 82
  • 125