Illegal Argument Exception - DrawerLayout must be measured with MeasureSpec.EXACTLY

后端 未结 4 722
再見小時候
再見小時候 2021-01-22 21:23

Stacktrace:

09-10 07:56:56.448  24867-24867/? E/AndroidRuntime﹕ FATAL EXCEPTION: main
    java.lang.IllegalArgumentException: DrawerLayout must          


        
4条回答
  •  無奈伤痛
    2021-01-22 21:50

    I tried lots of solution nothing worked.After a long time i found a solution by my self.

    i was using Linear Layout as a parent of my inflating class i just replaced with Relative Layout

    after that everything is working fine.For your better understanding given below is my code that i am using currently for inflating class

    FrameLayout layoutContainer = (FrameLayout ) findViewById(R.id.container);
        LayoutInflater layoutInflater = (LayoutInflater)
                this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
     layoutContainer.addView(layoutInflater.inflate(R.layout.ecom_home_activity, null));
    

    And ecom_home_activity is inflating class.The code of is given below.

    
    
    
    
        
    
        
    
        
    
    
    
    
    
    
    
    
    
    
    
    

    Previously i was using Linear layout of ecom_home_activity class i just changed Linear layout with Relative layout

    After that everything is working fine.In your case if you are using Linear Layout of your inflating class then Replace with Relative Layout.hope my answer will help you cheers.

提交回复
热议问题