Programmatically Modify ActionBarDrawerToggle Draw

2019-07-18 13:21发布

问题:

Does anyone know a way to get the drawable that is used for the ActionBarDrawerToggle after setting it in the constructor by resource ID? I am using a navigation drawer and I want to apply a color filter to the icon programmatically, but I can't figure out how to access it as a drawable. Any help would be appreciated. Thanks!

回答1:

As the framework's ID for that View is hidden, the only way I've found to access it is by walking through the hierarchy based on the Home View's position in it.

public ImageView getUpView()
{
    ViewGroup parentView = (ViewGroup) findViewById(android.R.id.home).getParent();
    return (ImageView) parentView.getChildAt(0);
}