Android Actionbar Left Menu

2019-06-24 00:34发布

I am working on android application. I have to add a menu on the left side of Action Bar. I am able to add menu on the right side but along with right side menu, I also want to add a menu on left side of Action Bar just like :

I have spent hours on searching how to achieve that left side menu, but no success. How can I achieve that? Thanks!

3条回答
Lonely孤独者°
2楼-- · 2019-06-24 01:16

You cant align menu to left .you should use customview for your actionbar

查看更多
爱情/是我丢掉的垃圾
3楼-- · 2019-06-24 01:21

This is called Navigation Drawer, You can look at the official android tutorial here, and this one too

查看更多
ら.Afraid
4楼-- · 2019-06-24 01:32

If you are not specifically into the navigational drawer, like a back button or anything you like, you can use

ActionBar actionbar = getSupportActionBar();
actionbar.setHomeAsUpIndicator(R.drawable.ic_arrow_back_black_24dp);

and call

@Override
    public boolean onOptionsItemSelected(MenuItem item) {
        if (item.getItemId() ==android.R.id.home){
            //todo work here
            return true;
        }
        return super.onOptionsItemSelected(item);
    }
查看更多
登录 后发表回答