android-如何从工具栏禁用DrawerArrowToggle或向右移动

第一个问题:
 我想创建一个从右到左的工具栏,如下图:

如何自定义工具栏DrawerArrowToggle向右移动?

第二个问题:
我创建了一个自定义工具栏,并为打开的抽屉创建了一个按钮,但是工具栏DrawerArrowToggle出现在我的自定义工具栏的左侧.

如何将其删除?

-更新-

通过添加sasikumar来感谢DrawerArrowToggle.

mDrawerToggle.setDrawerIndicatorEnabled(false);

这是我的工具栏代码:

 LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View view = inflater.inflate(R.layout.action_bar, null);
    ActionBar actionBar = getSupportActionBar();
    actionBar.setDisplayShowHomeEnabled(false);
    actionBar.setDisplayShowTitleEnabled(false);
    actionBar.setDisplayShowCustomEnabled(true);
    actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
    actionBar.setCustomView(view, new ActionBar.LayoutParams
            (ViewGroup.LayoutParams.MATCH_PARENT,
                    ViewGroup.LayoutParams.MATCH_PARENT));
    Toolbar parent = (Toolbar) view.getParent();
    parent.setContentInsetsAbsolute(0, 0);



Drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    mDrawerToggle = new ActionBarDrawerToggle(this, Drawer,
            parent, R.string.openDrawer,
            R.string.closeDrawer) {
        @Override
        public void onDrawerOpened(View drawerView) {
            super.onDrawerOpened(drawerView);


        }

        @Override
        public void onDrawerClosed(View drawerView) {
            super.onDrawerClosed(drawerView);

        }

        @Override
        public boolean onOptionsItemSelected(MenuItem item) {
            if (item != null && item.getItemId() == android.R.id.home) {
                if (Drawer.isDrawerOpen(Gravity.RIGHT)) {
                    Drawer.closeDrawer(Gravity.RIGHT);
                } else {
                    Drawer.openDrawer(Gravity.RIGHT);
                }
            }
            return false;
        }
    };
    Drawer.setDrawerListener(mDrawerToggle);
    mDrawerToggle.syncState();

我的欲望应用程序是这样的:

对不起,英语不好.

解决方法:

您可以使用onDrawerSlide方法隐藏箭头.

drawerToggle = new ActionBarDrawerToggle(this, drawerLayout,
    getToolbar(), R.string.open, R.string.close) {

@Override
public void onDrawerClosed(View view) {
    super.onDrawerClosed(view);
}

@Override
public void onDrawerOpened(View drawerView) {
    super.onDrawerOpened(drawerView);
}
 @Override
public void onDrawerSlide(View drawerView, float slideOffset) {
    super.onDrawerSlide(drawerView, 0); // this disables the animation 
}
};

如果要完全删除箭头,可以添加

super.onDrawerSlide(drawerView, 0); // this disables the arrow @ completed state

在onDrawerOpened函数的末尾

上一篇:ZTESTW_102


下一篇:Android Studio中没有全角工具栏?