答案 0 :(得分:0)
可能为时已晚,但......
实际上Mike在这里回答了类似问题Get reference to drawer toggle in support actionbar
我只是重用了他的代码。添加ActionBarDrawerToggle并在其上调用syncState()后
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();
你可以遍历工具栏的子项,然后......
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);
}
}
希望它有所帮助