当前位置: 首页 > 知识库问答 >
问题:

inflating类 android.support.design.widget.colllapsingToolbarLayout 时出错

贲培
2023-03-14

我试图让我的布局工作,将实现支持设计库功能。然而,当我尝试运行该项目,我得到以下异常时,我的布局是加载。

二进制XML文件行#2:inflating类android.support.design.widget.错误

这是我的布局:

<?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:在System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()[0x0000b]中的/Users/builder/data/lanes/2185/53fce373/source/mono/mcs/class/corlib/System.Runtime.IxceptionServices/ExceptionDefatchInfo.cs:61处引发了类型为“Android.Views.InflageException”的异常Android.App.Activity上的/Users/builder/data/lanes/2185/53fce373/source/monodroid/src/Mono.Android/src/RRuntime/JNIEnv.g.cs:1029中的(intptr,intptr、intptr和intptr)[0x00084]。/Users/builder/data/lanes/2185/53fce373/source/monodroid/src/Mono.Android/platforms/Android-23/src/generated/Android.App.Activity中的SetContentView(int)[0x00070]。cs:5872,位于Psonar.Apps.Droid.PayPerPlay.HomeActivity。OnCreate(Android.OS.Bundle)[0x00009]位于E:\Dev\psonar\Source\psonar.Apps\psonar.Apps.Droid\Psona.Apps.Droid.PayPerPlay\UI\HomeActivity中。cs:66,位于Android.Support.V4.App.FragmentActivity。n_OnCreate_Landroid_os_Bundle_(intptr、intptr和intptr)at(包装器动态方法)对象。14ce2242-aa35-41bb-a113-286527a98d77(整数,整数,整数)

--- 托管异常堆栈跟踪结束 --- android.view.InflateException: 二进制 XML 文件行 #2: inflating类时出错 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) atandroid.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) atandroid.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:109) at md5cdb4fd1f07f997be815955fad4cc2feb.HomeActivity.n_onCreate(本机方法) 在 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.access$800(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) 由以下原因引起: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.NoSuchField错误: 类 Landroid/support/design/R$styleable 中没有类型 I 的静态字段TextAppearance_android_shadowColor;或其超类('android.support.design.R$styleable' 的声明出现在 android.support.design.widget.CollapsingTextHelper.setExpandedTextAppearance(CollapsingTextHelper.java:230) 的 android.support.design.widget.CollapsingToolbarLayout 的 /data/app/com.psonar.android-1/base.apk 中。(CollapsingToolbarLayout.java:185) at android.support.design.widget.CollapsingToolbarLayout.(折叠工具栏布局.java:126) ...28 更多 }

共有1个答案

柯新翰
2023-03-14

我希望解决方案是别的东西,但简单的重新安装支持设计库软件包就可以了。我不得不通过Xamarin Studio来完成,尽管Visual Studio在这种情况下行为不当。

 类似资料: