DecorView子framelayout在设备上有所不同

Seo*_* So 2 android android-framelayout

我使用类似的库 github.com/bk138/LibSlideMenu

并且它的工作非常出色HTC device(ICS),并Nexus 7(ICS)和其他Gingerbread设备.

但有些设备Motorola atrix和其他HTC设备一样.

所以我检查了代码.

View view  = act.findViewById(android.R.id.content);
Utils.Log("<SlideMenu> : VIEW : "+view);        
ViewParent viewParent = view.getParent();
Utils.Log("<SlideMenu> : VIEW : "+viewParent);  
LinearLayout linearLayout = (LinearLayout) viewParent;
Utils.Log("<SlideMenu> : VIEW : "+linearLayout);
content = linearLayout;
Run Code Online (Sandbox Code Playgroud)

在这里,首先FrameLayout在所有设备上返回.

但第二件事LinearLayoutICS设备和其他HTC 2.3设备上返回,有些设备返回DecorView.

我引用这篇文章:DecorView Child FrameLayout

他们说这是我使用的问题NoTitleBar,所以我显示标题栏但它不起作用.

此外,即使我添加了NoTitleBar属性,一些设备也能很好地工作.

由于设备有不同的结果,这真的令人沮丧.有谁知道吗?

请帮助:D提前致谢.

Mat*_*ker 6

我相信我们可以肯定一些关于PhoneWindow $ DecorView的东西(或者至少可以确定为Android开发的东西).

首先,DecorView扩展了FrameLayout,因此,我们可以放心地将其转换为父类ViewGroup.也就是说,其次,我们也可以确信DecorView包含父类View(否则它将是一个相当无聊的ViewGroup不会).

这使我得出结论,这个问题应该从上到下受到攻击而不是自下而上,因为有问题的库代码正在尝试.

例如这样的事情:

ViewGroup decorView = (ViewGroup) getWindow().getDecorView();
View oldScreen = decorView.getChildAt(0);
decorView.removeViewAt(0);
LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
SlidingPanel slidingPanel = (SlidingPanel) inflater.inflate(R.layout.screen_slider, null);
((ViewGroup) slidingPanel.findViewById(R.id.anterior)).addView(oldScreen);
decorView.addView(slidingPanel, 0);
Run Code Online (Sandbox Code Playgroud)

我最近实现了一个类似的基本SlidingPanel小部件,并按照上面的说法使用它.你可以在这里找到它和进一步的示例用法https://github.com/mubeta06/android/tree/master/SlidingFrame.