错误膨胀 class android.support.design.widget.CollapsingToolbarLayout
Error inflating class android.support.design.widget.CollapsingToolbarLayout
我正在尝试让我的布局正常工作以实现支持设计库功能。但是,当我尝试 运行 项目时,我在加载布局时遇到异常。
Android.Views.InflateException: Binary XML file line #2: Error
inflating class android.support.design.widget.CollapsingToolbarLayout
这是我的布局:
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<!-- As the main content view, the view below consumes the entire
space available using match_parent in both dimensions. -->
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/main_grey">
<android.support.design.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<android.support.design.widget.AppBarLayout
android:layout_height="192dp"
android:layout_width="match_parent">
<android.support.design.widget.CollapsingToolbarLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_scrollFlags="scroll"
>
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="60dp"
android:minHeight="60dp"
android:background="@drawable/actionbar_background">
<ImageView
android:id="@+id/psonar_logo"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_gravity="top|center_horizontal"
android:visibility="gone" />
<RelativeLayout
android:id="@+id/toolbarTitles"
android:layout_alignParentLeft="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="gone">
<TextView
android:id="@+id/toolbarTitle"
android:ellipsize="end"
android:maxLines="1"
android:textSize="18dp"
android:textColor="@color/white"
android:layout_alignParentLeft="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/toolbarSubtitle"
android:ellipsize="end"
android:maxLines="1"
android:textColor="@color/white"
android:gravity="center_vertical"
android:visibility="gone"
android:layout_alignParentLeft="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/toolbarTitle" />
</RelativeLayout>
</android.support.v7.widget.Toolbar>
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<android.support.v4.widget.NestedScrollView
android:id="@+id/scroll"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipToPadding="false"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<FrameLayout
android:minWidth="25px"
android:minHeight="25px"
android:layout_width="match_parent"
android:layout_height="175dp"
android:id="@+id/carouselFrameLayout" />
</android.support.v4.widget.NestedScrollView>
</android.support.design.widget.CoordinatorLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/toolbar"
android:layout_above="@id/miniPlayerHolder"
android:background="@color/main_grey"
android:animateLayoutChanges="true"
android:orientation="vertical">
<TabHost
android:id="@android:id/tabhost"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TabWidget
android:id="@android:id/tabs"
android:layout_width="match_parent"
android:layout_height="45dp"
android:tabStripEnabled="false"
android:layout_weight="0"
android:showDividers="none" />
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_weight="0" />
<android.support.v4.view.ViewPager
android:id="@+id/pager"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" />
</LinearLayout>
</TabHost>
</LinearLayout>
<include
layout="@layout/mini_player_holder" />
</RelativeLayout>
<!-- android:layout_gravity="start" tells DrawerLayout to treat
this as a sliding drawer on the left side for left-to-right
languages and on the right side for right-to-left languages.
The drawer is given a fixed width in dp and extends the full height of
the container. A solid background is used for contrast
with the content view. -->
<include
layout="@layout/home_drawer_menu" />
</android.support.v4.widget.DrawerLayout>
我尝试构建实施 CollapsingToolbarLayout 的简单测试项目,它工作时没有任何问题,但是当我尝试将它放入我的项目时它停止工作。
我检查了 nuget 包,它们似乎安装得很好。我们的主题继承自:Theme.AppCompat.NoActionBar.
堆栈跟踪:
{Android.Views.InflateException: Exception of type
'Android.Views.InflateException' was thrown. at
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw ()
[0x0000b] in
/Users/builder/data/lanes/2185/53fce373/source/mono/mcs/class/corlib/System.Runtime.ExceptionServices/ExceptionDispatchInfo.cs:61
at Android.Runtime.JNIEnv.CallNonvirtualVoidMethod
(intptr,intptr,intptr,Android.Runtime.JValue*) [0x00084] in
/Users/builder/data/lanes/2185/53fce373/source/monodroid/src/Mono.Android/src/Runtime/JNIEnv.g.cs:1029
at Android.App.Activity.SetContentView (int) [0x00070] in
/Users/builder/data/lanes/2185/53fce373/source/monodroid/src/Mono.Android/platforms/android-23/src/generated/Android.App.Activity.cs:5872
at Psonar.Apps.Droid.PayPerPlay.HomeActivity.OnCreate
(Android.OS.Bundle) [0x00009] in
E:\Dev\psonar\Source\Psonar.Apps\Psonar.Apps.Droid\Psonar.Apps.Droid.PayPerPlay\UI\HomeActivity.cs:66
at
Android.Support.V4.App.FragmentActivity.n_OnCreate_Landroid_os_Bundle_
(intptr,intptr,intptr) at (wrapper
dynamic-method) object.14ce2242-aa35-41bb-a113-286527a98d77
(intptr,intptr,intptr)
--- End of managed exception stack trace ---
android.view.InflateException: Binary XML file line #2: Error
inflating class android.support.design.widget.CollapsingToolbarLayout
at android.view.LayoutInflater.createView(LayoutInflater.java:633)
at
android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:743)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:806) at
android.view.LayoutInflater.rInflate(LayoutInflater.java:809) at
android.view.LayoutInflater.rInflate(LayoutInflater.java:809) at
android.view.LayoutInflater.rInflate(LayoutInflater.java:809) at
android.view.LayoutInflater.inflate(LayoutInflater.java:504) at
android.view.LayoutInflater.inflate(LayoutInflater.java:414) at
android.view.LayoutInflater.inflate(LayoutInflater.java:365) at
android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:255)
at
android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:109)
at md5cdb4fd1f07f997be815955fad4cc2feb.HomeActivity.n_onCreate(Native
Method) at
md5cdb4fd1f07f997be815955fad4cc2feb.HomeActivity.onCreate(HomeActivity.java:38)
at android.app.Activity.performCreate(Activity.java:5990) at
android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106)
at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2278)
at
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387)
at android.app.ActivityThread.access0(ActivityThread.java:151) at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303)
at android.os.Handler.dispatchMessage(Handler.java:102) at
android.os.Looper.loop(Looper.java:135) at
android.app.ActivityThread.main(ActivityThread.java:5254) at
java.lang.reflect.Method.invoke(Native Method) at
java.lang.reflect.Method.invoke(Method.java:372) at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
Caused by: java.lang.reflect.InvocationTargetException at
java.lang.reflect.Constructor.newInstance(Native Method) at
java.lang.reflect.Constructor.newInstance(Constructor.java:288) at
android.view.LayoutInflater.createView(LayoutInflater.java:607) ...
25 more Caused by: java.lang.NoSuchFieldError: No static field
TextAppearance_android_shadowColor of type I in class
Landroid/support/design/R$styleable; or its superclasses (declaration
of 'android.support.design.R$styleable' appears in
/data/app/com.psonar.android-1/base.apk) at
android.support.design.widget.CollapsingTextHelper.setExpandedTextAppearance(CollapsingTextHelper.java:230)
at
android.support.design.widget.CollapsingToolbarLayout.(CollapsingToolbarLayout.java:185)
at
android.support.design.widget.CollapsingToolbarLayout.(CollapsingToolbarLayout.java:126)
... 28 more }
我希望解决方案是别的,但简单地重新安装支持设计库包就可以了。我必须通过 Xamarin Studio 来完成,因为 Visual Studio 在这种情况下行为不端。
我正在尝试让我的布局正常工作以实现支持设计库功能。但是,当我尝试 运行 项目时,我在加载布局时遇到异常。
Android.Views.InflateException: Binary XML file line #2: Error inflating class android.support.design.widget.CollapsingToolbarLayout
这是我的布局:
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<!-- As the main content view, the view below consumes the entire
space available using match_parent in both dimensions. -->
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/main_grey">
<android.support.design.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<android.support.design.widget.AppBarLayout
android:layout_height="192dp"
android:layout_width="match_parent">
<android.support.design.widget.CollapsingToolbarLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_scrollFlags="scroll"
>
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="60dp"
android:minHeight="60dp"
android:background="@drawable/actionbar_background">
<ImageView
android:id="@+id/psonar_logo"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_gravity="top|center_horizontal"
android:visibility="gone" />
<RelativeLayout
android:id="@+id/toolbarTitles"
android:layout_alignParentLeft="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="gone">
<TextView
android:id="@+id/toolbarTitle"
android:ellipsize="end"
android:maxLines="1"
android:textSize="18dp"
android:textColor="@color/white"
android:layout_alignParentLeft="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/toolbarSubtitle"
android:ellipsize="end"
android:maxLines="1"
android:textColor="@color/white"
android:gravity="center_vertical"
android:visibility="gone"
android:layout_alignParentLeft="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/toolbarTitle" />
</RelativeLayout>
</android.support.v7.widget.Toolbar>
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<android.support.v4.widget.NestedScrollView
android:id="@+id/scroll"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipToPadding="false"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<FrameLayout
android:minWidth="25px"
android:minHeight="25px"
android:layout_width="match_parent"
android:layout_height="175dp"
android:id="@+id/carouselFrameLayout" />
</android.support.v4.widget.NestedScrollView>
</android.support.design.widget.CoordinatorLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/toolbar"
android:layout_above="@id/miniPlayerHolder"
android:background="@color/main_grey"
android:animateLayoutChanges="true"
android:orientation="vertical">
<TabHost
android:id="@android:id/tabhost"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TabWidget
android:id="@android:id/tabs"
android:layout_width="match_parent"
android:layout_height="45dp"
android:tabStripEnabled="false"
android:layout_weight="0"
android:showDividers="none" />
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_weight="0" />
<android.support.v4.view.ViewPager
android:id="@+id/pager"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" />
</LinearLayout>
</TabHost>
</LinearLayout>
<include
layout="@layout/mini_player_holder" />
</RelativeLayout>
<!-- android:layout_gravity="start" tells DrawerLayout to treat
this as a sliding drawer on the left side for left-to-right
languages and on the right side for right-to-left languages.
The drawer is given a fixed width in dp and extends the full height of
the container. A solid background is used for contrast
with the content view. -->
<include
layout="@layout/home_drawer_menu" />
</android.support.v4.widget.DrawerLayout>
我尝试构建实施 CollapsingToolbarLayout 的简单测试项目,它工作时没有任何问题,但是当我尝试将它放入我的项目时它停止工作。
我检查了 nuget 包,它们似乎安装得很好。我们的主题继承自:Theme.AppCompat.NoActionBar.
堆栈跟踪:
{Android.Views.InflateException: Exception of type 'Android.Views.InflateException' was thrown. at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000b] in /Users/builder/data/lanes/2185/53fce373/source/mono/mcs/class/corlib/System.Runtime.ExceptionServices/ExceptionDispatchInfo.cs:61 at Android.Runtime.JNIEnv.CallNonvirtualVoidMethod (intptr,intptr,intptr,Android.Runtime.JValue*) [0x00084] in /Users/builder/data/lanes/2185/53fce373/source/monodroid/src/Mono.Android/src/Runtime/JNIEnv.g.cs:1029 at Android.App.Activity.SetContentView (int) [0x00070] in /Users/builder/data/lanes/2185/53fce373/source/monodroid/src/Mono.Android/platforms/android-23/src/generated/Android.App.Activity.cs:5872 at Psonar.Apps.Droid.PayPerPlay.HomeActivity.OnCreate (Android.OS.Bundle) [0x00009] in E:\Dev\psonar\Source\Psonar.Apps\Psonar.Apps.Droid\Psonar.Apps.Droid.PayPerPlay\UI\HomeActivity.cs:66 at Android.Support.V4.App.FragmentActivity.n_OnCreate_Landroid_os_Bundle_ (intptr,intptr,intptr) at (wrapper dynamic-method) object.14ce2242-aa35-41bb-a113-286527a98d77 (intptr,intptr,intptr)
--- End of managed exception stack trace --- android.view.InflateException: Binary XML file line #2: Error inflating class android.support.design.widget.CollapsingToolbarLayout at android.view.LayoutInflater.createView(LayoutInflater.java:633) at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:743) at android.view.LayoutInflater.rInflate(LayoutInflater.java:806) at android.view.LayoutInflater.rInflate(LayoutInflater.java:809) at android.view.LayoutInflater.rInflate(LayoutInflater.java:809) at android.view.LayoutInflater.rInflate(LayoutInflater.java:809) at android.view.LayoutInflater.inflate(LayoutInflater.java:504) at android.view.LayoutInflater.inflate(LayoutInflater.java:414) at android.view.LayoutInflater.inflate(LayoutInflater.java:365) at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:255) at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:109) at md5cdb4fd1f07f997be815955fad4cc2feb.HomeActivity.n_onCreate(Native Method) at md5cdb4fd1f07f997be815955fad4cc2feb.HomeActivity.onCreate(HomeActivity.java:38) at android.app.Activity.performCreate(Activity.java:5990) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2278) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387) at android.app.ActivityThread.access0(ActivityThread.java:151) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:135) at android.app.ActivityThread.main(ActivityThread.java:5254) at java.lang.reflect.Method.invoke(Native Method) at java.lang.reflect.Method.invoke(Method.java:372) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698) Caused by: java.lang.reflect.InvocationTargetException at java.lang.reflect.Constructor.newInstance(Native Method) at java.lang.reflect.Constructor.newInstance(Constructor.java:288) at android.view.LayoutInflater.createView(LayoutInflater.java:607) ... 25 more Caused by: java.lang.NoSuchFieldError: No static field TextAppearance_android_shadowColor of type I in class Landroid/support/design/R$styleable; or its superclasses (declaration of 'android.support.design.R$styleable' appears in /data/app/com.psonar.android-1/base.apk) at android.support.design.widget.CollapsingTextHelper.setExpandedTextAppearance(CollapsingTextHelper.java:230) at android.support.design.widget.CollapsingToolbarLayout.(CollapsingToolbarLayout.java:185) at android.support.design.widget.CollapsingToolbarLayout.(CollapsingToolbarLayout.java:126) ... 28 more }
我希望解决方案是别的,但简单地重新安装支持设计库包就可以了。我必须通过 Xamarin Studio 来完成,因为 Visual Studio 在这种情况下行为不端。