简体   繁体   中英

padding to ActionBarDrawerToggle

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

But by default it gives some space from the edge. 在此处输入图片说明

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM