在Android的导航抽屉里是不是全屏幕 [英] Navigation drawer in android is not full screen

查看:314
本文介绍了在Android的导航抽屉里是不是全屏幕的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于谷歌已经推出了导航抽屉里,我试图用这个组件来创建一个类似Facebook的菜单。问题是,该视觉效果似乎是不同的。

的谷歌人有操作栏保留在抽屉是打开的,而facebook的人做not.Instead,整个屏幕已经被推到右侧

我发现有一些lib中能做到这一点,但因为我preFER不包括第三方的lib项目,还有什么办法来实现这一目标?谢谢

根据抽屉式导航教程code

 保护无效setupMenu(名单<字符串>名单,最终的ListView菜单){
        适配器customAdapter =新的适配器(getActionBar()。getThemedContext()
                R.layout.item,清​​单);
        menu.setAdapter(customAdapter);
        menu.setOnItemClickListener(新OnItemClickListener(){
            @覆盖
            公共无效onItemClick(适配器视图<>母公司视图中查看,
                    最终诠释POS,长I​​D){
                字符串选择=((TextView中)view.findViewById(R.id.itemTxt))
                        .getText()的toString()。
                //定义传数据
                最终捆绑BDATA =新包();
                bData.putString(itemSelect,选定的);

                drawer.setDrawerListener(新DrawerLayout.SimpleDrawerListener(){
                    @覆盖
                    公共无效onDrawerClosed(查看drawerView){
                        super.onDrawerClosed(drawerView);
                        FragmentTransaction TX = getSupportFragmentManager()
                                .beginTransaction();
                        tx.replace(R.id.mainContent,Fragment.instantiate(
                                MainActivity.this,
                                com.example.utilities.ContentPage,BDATA));
                        tx.commit();
                    }
                });

                drawer.closeDrawer(菜单);
            }
        });

    }
 

解决方案

那么创建一个自定义导航抽屉是您的最佳解决方案。 我知道你不希望使用第三方但这可能是一个快速的解决您的问题滑动菜单库链接

Since the google has introduced the navigation drawer, I tried to use this component to create a facebook-like menu. The problem is , the visual effect is seems to be different.

The google one has the action bar retain when the drawer is open while the facebook one does not.Instead, the whole screen has pushed to right side

I have found there are some lib can achieve this, but since I prefer not include third party lib in the project, are there any way to achieve this ? Thanks

Code based on navigation drawer tutorial

protected void setupMenu(List<String> list, final ListView menu) {
        Adapter customAdapter = new Adapter(getActionBar().getThemedContext(),
                R.layout.item, list);
        menu.setAdapter(customAdapter);
        menu.setOnItemClickListener(new OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view,
                    final int pos, long id) {
                String selected = ((TextView) view.findViewById(R.id.itemTxt))
                        .getText().toString();
                // define pass data
                final Bundle bData = new Bundle();
                bData.putString("itemSelect", selected);

                drawer.setDrawerListener(new DrawerLayout.SimpleDrawerListener() {
                    @Override
                    public void onDrawerClosed(View drawerView) {
                        super.onDrawerClosed(drawerView);
                        FragmentTransaction tx = getSupportFragmentManager()
                                .beginTransaction();
                        tx.replace(R.id.mainContent, Fragment.instantiate(
                                MainActivity.this,
                                "com.example.utilities.ContentPage", bData));
                        tx.commit();
                    }
                });

                drawer.closeDrawer(menu);
            }
        });

    }

解决方案

Well creating a custom navigation drawer is the best solution for you. I understand you do not want to use third party but this can be a quick solution to your problem Sliding Menu Lib link.

这篇关于在Android的导航抽屉里是不是全屏幕的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆