android DrawerLayout 点击穿透、点击自身消失等问题解决

问题1:在DrawerLayout内部中点击,DrawerLayout的布局莫名消失。

解决1:DrawerLayout的布局必须放在页面主布局的下面。

To use a DrawerLayout, position your primary content view as the first child with a width and height of match_parent. Add drawers as child views after the main content view and set the layout_gravity appropriately. Drawers commonly use match_parent for height with a fixed width.

问题2:点击DrawerLayout的布局,会触发被滑出页面挡住的布局中的点击事件。

解决2:在DrawerLayout的最外层布局中,设置android:clickable="true"

问题3: java.lang.IllegalArgumentException: DrawerLayout must be measured with MeasureSpec.EXACTLY.

解决3:设置DrawerLayout的height为 match_parent.
Drawers commonly use match_parent for height with a fixed width.

下面贴上一段代码供大家参考:



    
    
         ............
         主布局代码 
         ............
         ............
    

    
    

        

            

            
        
        
    



你可能感兴趣的:(Android)