该getDecorView方法返回查看包括棒棒糖导航栏的看法

该getDecorView方法返回查看包括棒棒糖导航栏的看法

本文介绍了该getDecorView方法返回查看包括棒棒糖导航栏的看法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 SlidingMenu 实现我的滑盖式菜单。

在code是

后来我有一个问题,就是我的导航栏后面的布局。

和我改变SlidingMenu.SLIDING_WINDOW到Sli​​dingMenu.SLIDING_CONTENT。它的作品,但始终在顶部的动作条。

看SlidingMenu源$ C ​​$ C,我觉得这是code添加slidingmenu。

 开关(slideStyle){
    案例SLIDING_WINDOW:
        mActionbarOverlay = FALSE;
        ViewGroup中的装饰=(ViewGroup中)activity.getWindow()getDecorView()。
        ViewGroup中decorChild =(ViewGroup中)decor.getChildAt(0);
        //保存动作条的主题,有透明的资产
        decorChild.setBackgroundResource(背景);
        decor.removeView(decorChild);
        decor.addView(本);
        setContent(decorChild);
        打破;
    案例SLIDING_CONTENT:
        mActionbarOverlay = actionbarOverlay;
        //把上述观点出
        ViewGroup中contentParent =(ViewGroup中)activity.findViewById(android.R.id.content);
        查看内容= contentParent.getChildAt(0);
        contentParent.removeView(内容);
        contentParent.addView(本);
        setContent(内容);
        //救人具有透明背景
        如果(content.getBackground()== NULL)
            content.setBackgroundResource(背景);
        打破;
    }
 

我该如何解决呢?这一问题只在安卓5.0棒棒糖找到。

解决方案

SlidingMenu在GitHub上开设了相同的问题

 私人诠释getNavigationBarHeight(){
    资源资源= getResources();
    INT RESOURCEID = resources.getIdentifier(navigation_bar_height,地扪,机器人);
    如果(RESOURCEID大于0){
        返回resources.getDimensionPixelSize(RESOURCEID);
    }
    返回0;
}

@覆盖
公共无效的onCreate(包savedInstanceState){
    如果(Build.VERSION.SDK_INT> = Build.VERSION_ codeS.LOLLIPOP){
        INT navBarHeight = getNavigationBarHeight();
        findViewById(R.id.base_frame).setPadding(0,0,0,navBarHeight);
        findViewById(R.id.menu_frame).setPadding(0,0,0,navBarHeight);
    }
}
 

I use SlidingMenu to implement my slide-in menus.

The code is

Then I got a problem is my layout behind of navigation bar.

And i change the SlidingMenu.SLIDING_WINDOW to SlidingMenu.SLIDING_CONTENT.It's works,but the actionbar always on the top.

Look at the source code of SlidingMenu,i find this code to add slidingmenu.

    switch (slideStyle) {
    case SLIDING_WINDOW:
        mActionbarOverlay = false;
        ViewGroup decor = (ViewGroup) activity.getWindow().getDecorView();
        ViewGroup decorChild = (ViewGroup) decor.getChildAt(0);
        // save ActionBar themes that have transparent assets
        decorChild.setBackgroundResource(background);
        decor.removeView(decorChild);
        decor.addView(this);
        setContent(decorChild);
        break;
    case SLIDING_CONTENT:
        mActionbarOverlay = actionbarOverlay;
        // take the above view out of
        ViewGroup contentParent = (ViewGroup)activity.findViewById(android.R.id.content);
        View content = contentParent.getChildAt(0);
        contentParent.removeView(content);
        contentParent.addView(this);
        setContent(content);
        // save people from having transparent backgrounds
        if (content.getBackground() == null)
            content.setBackgroundResource(background);
        break;
    }

How can i fix it?This bug only found in Android 5.0 lollipop.

解决方案

SlidingMenu on GitHub has opened same issue.

private int getNavigationBarHeight() {
    Resources resources = getResources();
    int resourceId = resources.getIdentifier("navigation_bar_height", "dimen", "android");
    if (resourceId > 0) {
        return resources.getDimensionPixelSize(resourceId);
    }
    return 0;
}

@Override
public void onCreate(Bundle savedInstanceState) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        int navBarHeight = getNavigationBarHeight();
        findViewById(R.id.base_frame).setPadding(0, 0, 0, navBarHeight);
        findViewById(R.id.menu_frame).setPadding(0, 0, 0, navBarHeight);
    }
}

这篇关于该getDecorView方法返回查看包括棒棒糖导航栏的看法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-24 12:08