ClassCastException: android.widget.LinearLayout $ LayoutParams cannot be added to com.android.internal.widget.ActionBarOverlayLayout $ LayoutParams

I converted the Eclipse project to an Android Studio project, and when I started the application, I received the following exception:

java.lang.ClassCastException: android.widget.LinearLayout$LayoutParams cannot be cast to com.android.internal.widget.ActionBarOverlayLayout$LayoutParams at com.android.internal.widget.ActionBarOverlayLayout.applyInsets(ActionBarOverlayLayout.java:172) at com.android.internal.widget.ActionBarOverlayLayout.onMeasure(ActionBarOverlayLayout.java:317) at android.view.View.measure(View.java:16497) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5125) at android.widget.FrameLayout.onMeasure(FrameLayout.java:310) at com.android.internal.policy.impl.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2291) at android.view.View.measure(View.java:16497) at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:1912) at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1109) at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1291) at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:996) at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5600) at android.view.Choreographer$CallbackRecord.run(Choreographer.java:761) at android.view.Choreographer.doCallbacks(Choreographer.java:574) at android.view.Choreographer.doFrame(Choreographer.java:544) at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:747) at android.os.Handler.handleCallback(Handler.java:733) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:136) at android.app.ActivityThread.main(ActivityThread.java:5001) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:515) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601) at dalvik.system.NativeStart.main(Native Method) 

My theme:

 <style name="AppBaseTheme" parent="Theme.AppCompat" /> <!-- Application theme. --> <style name="AppTheme" parent="AppBaseTheme"> <item name="windowActionBar">false</item> <item name="windowNoTitle">true</item> <item name="colorPrimary">@color/primary</item> <item name="colorPrimaryDark">@color/primary_dark</item> <item name="colorAccent">@color/accent</item> <item name="android:textColorPrimary">@color/primary_text</item> </style> 

My activity is extended by AppCompactActivity , and its layout is:

 <android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/drawer_layout" android:layout_width="match_parent" android:layout_height="match_parent" android:fitsSystemWindows="true"> <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <include layout="@layout/toolbar" /> <!-- Your normal content view --> <FrameLayout android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1"> <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <!-- <include layout="@layout/toolbar" /> --> <FrameLayout android:id="@+id/frag_container" android:layout_width="match_parent" android:layout_height="match_parent"></FrameLayout> <!-- The navigation drawer --> </LinearLayout> <View android:layout_width="match_parent" android:layout_height="5dp" android:background="@drawable/toolbar_shadow" /> </FrameLayout> </LinearLayout> <!-- Your drawer view. This can be any view, LinearLayout --> <!-- is just an example. As we have set fitSystemWindows=true --> <!-- this will be displayed under the status bar. --> <LinearLayout android:id="@+id/drawer_view" android:layout_width="304dp" android:layout_height="match_parent" android:layout_gravity="left|start" android:fitsSystemWindows="true"> <!-- Your drawer content --> <ListView android:id="@+id/left_drawer" style="@style/NavDrawer" android:layout_width="320dp" android:layout_height="match_parent" android:layout_gravity="start" android:background="@color/icons" android:choiceMode="singleChoice" android:divider="@color/divider" android:dividerHeight="0dp" android:listSelector="@drawable/drawer_listview_background_selector" /> </LinearLayout> </android.support.v4.widget.DrawerLayout> 

Please note that I have included the following topics in the topic after reading this SO thread

 <item name="windowActionBar">false</item> <item name="windowNoTitle">true</item> 

The project has the following dependencies:

 dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) compile 'com.github.navasmdc:MaterialDesign: 1.+@aar ' compile fileTree(dir: 'libs', include: ['*.jar']) compile 'com.android.support:cardview-v7:22.1.1' compile 'com.android.support:appcompat-v7:22.1.1' compile 'com.wrapp.floatlabelededittext:library:0.0.6' compile 'com.android.support:recyclerview-v7:22.1.1' compile 'com.github.flavienlaurent.datetimepicker:library:0.0.2' compile('com.mikepenz.materialdrawer:library: 2.9.1@aar ') { transitive = true } compile 'com.google.android.gms:play-services:7.0.0' compile 'com.anjlab.android.iab.v3:library: 1.0.+@aar ' compile 'com.github.alamkanak:android-week-view:1.2.1' compile 'com.github.johnkil.android-robototextview:robototextview:2.4.0' // AboutLibraries Library compile('com.mikepenz.aboutlibraries:library: 4.7.2@aar ') { transitive = true } // ChangeLog Libraries compile 'com.github.gabrielemariotti.changeloglib:library:1.5.2' compile files('libs/universal-image-loader-1.9.3-with-sources.jar') compile 'de.greenrobot:eventbus:2.4.0' compile 'com.twotoasters.SectionCursorAdapter:library:1.0.+' compile 'com.larswerkman:HoloColorPicker:1.5' compile('com.crashlytics.sdk.android:crashlytics: 2.2.3@aar ') { transitive = true; } } 
+5
source share
1 answer

I faced the same problem, I changed my style to the next and decided.

Before

  <style name="ImageViewer" parent="AppTheme.NoActionBar"> <item name="windowActionBar">false</item> <item name="windowNoTitle">true</item> <item name="android:windowIsTranslucent">true</item> </style> 

After

  <style name="ImageViewer" parent="AppTheme.NoActionBar"> <!--<item name="windowActionBar">false</item>--> <!--<item name="windowNoTitle">true</item>--> <!--<item name="android:windowIsTranslucent">true</item>--> </style> 

And my theme is NoActionBar

  <style name="AppTheme.NoActionBar"> <item name="windowActionBar">false</item> <item name="windowNoTitle">true</item> </style> 
0
source

All Articles