gpt4 book ai didi

java - ClassCastException : android. widget.LinearLayout$LayoutParams 无法转换为 com.android.internal.widget.ActionBarOverlayLayout$LayoutParams

转载 作者:塔克拉玛干 更新时间:2023-11-02 21:37:55 25 4
gpt4 key购买 nike

我已将我的 Eclipse 项目转换为 Android Studio 项目,当我运行该应用程序时出现以下异常:

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)

我的主题是:

<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>

我的 Activity 正在扩展 AppCompactActivity,它的布局是:

<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>

请注意,在阅读 this SO thread 后,我在主题中包含了以下项目

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

该项目具有以下依赖项:

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;
}
}

最佳答案

我遇到了同样的问题,我改变了我的风格,然后解决了。

之前

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

之后

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

我的 NoActionBar 主题是

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

关于java - ClassCastException : android. widget.LinearLayout$LayoutParams 无法转换为 com.android.internal.widget.ActionBarOverlayLayout$LayoutParams,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30004814/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com