如果您正在使用Toolbar
的DrawerLayout
內 - >AppBarLayout
那麼類
ActionBarDrawerToggle-->setDrawerIndicatorEnabled(false)
功能將使導航抽屜圖標invisible.like
public class MainActivity extends AppCompatActivity
implements NavigationView.OnNavigationItemSelectedListener
{
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
drawer.addDrawerListener(toggle);
//the below line of code will allow you to hide the nav drawer icon
toggle.setDrawerIndicatorEnabled(false);
toggle.syncState();
NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
navigationView.setNavigationItemSelectedListener(this);
}
謝謝,這似乎隱藏導航圖標,但我沒有使用setIcon的自定義圖標。那麼,我將如何獲取導航抽屜指標。 – harshitpthk 2015-03-02 07:06:18
感謝它使用toolbar.setNavigationIcon(getResources()。getDrawable(R.drawable.abc_ic_ab_back_mtrl_am_alpha)); – harshitpthk 2015-03-02 07:15:31