我正在努力让我的布局正常工作,以实现支持设计库的功能。但是,当我尝试运行项目时,我在加载布局时遇到异常。
Android.Views.InflateException:二进制XML文件行#2:错误 膨胀类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:类型异常 &#39; Android.Views.InflateException&#39;被扔了。在 System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() [0x0000b] in /Users/builder/data/lanes/2185/53fce373/source/mono/mcs/class/corlib/System.Runtime.ExceptionServices/ExceptionDispatchInfo.cs:61 在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 在Android.App.Activity.SetContentView(int)[0x00070]中 /Users/builder/data/lanes/2185/53fce373/source/monodroid/src/Mono.Android/platforms/android-23/src/generated/Android.App.Activity.cs:5872 在Psonar.Apps.Droid.PayPerPlay.HomeActivity.OnCreate (Android.OS.Bundle)[0x00009] in E:\开发\ psonar \来源\ Psonar.Apps \ Psonar.Apps.Droid \ Psonar.Apps.Droid.PayPerPlay \ UI \ HomeActivity.cs:66 在 Android.Support.V4.App.FragmentActivity.n_OnCreate_Landroid_os_Bundle_ (intptr,intptr,intptr)at(包装器 dynamic-method)object.14ce2242-aa35-41bb-a113-286527a98d77 (intptr,intptr,intptr)
---托管异常堆栈跟踪结束--- android.view.InflateException:二进制XML文件行#2:错误 inflating类android.support.design.widget.CollapsingToolbarLayout 在android.view.LayoutInflater.createView(LayoutInflater.java:633) 在 android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:743) 在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) 在 android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:109) at md5cdb4fd1f07f997be815955fad4cc2feb.HomeActivity.n_onCreate(Native 方法)at md5cdb4fd1f07f997be815955fad4cc2feb.HomeActivity.onCreate(HomeActivity.java:38) 在android.app.Activity.performCreate(Activity.java:5990)处 android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106) 在 android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2278) 在 android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387) 在android.app.ActivityThread.access $ 800(ActivityThread.java:151)at android.app.ActivityThread $ H.handleMessage(ActivityThread.java:1303) 在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) 在com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698) 引起: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更多引起:java.lang.NoSuchFieldError:没有静态字段 类中的类型I的TextAppearance_android_shadowColor Landroid /支持/设计/ R $设置样式;或其超类(声明 of&#39; android.support.design.R $ styleable&#39;出现在 /data/app/com.psonar.android-1/base.apk)at android.support.design.widget.CollapsingTextHelper.setExpandedTextAppearance(CollapsingTextHelper.java:230) 在 android.support.design.widget.CollapsingToolbarLayout。(CollapsingToolbarLayout.java:185) 在 android.support.design.widget.CollapsingToolbarLayout。(CollapsingToolbarLayout.java:126) ...... 28更多}
答案 0 :(得分:0)
我希望解决方案是别的,但简单的重新安装支持设计库包就可以了。我不得不通过Xamarin Studio来做这件事,因为Visual Studio在这种情况下行为不端。