【发布时间】:2017-02-11 06:50:32
【问题描述】:
我对这段代码有疑问。当我在 kitkat 中运行它时,它会提示一个未处理的异常
Android.Views.InflateException:二进制 XML 文件第 1 行:膨胀类工具栏时出错
顺便说一句:我也用过
...
android.support.v7.widget.Toolbar >
正如其他问题中所建议的,但它仍然是一样的。
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<!--Error came from this toolbar-->
<Toolbar
android:minHeight="30dp"
android:layout_width="match_parent"
android:layout_height="30dp"
android:background="@color/lime"
android:id="@+id/toolbar"
android:elevation="6dp">
<TextView
android:text="BranchName"
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="left"
android:layout_marginRight="155dp"
android:id="@+id/branchName"
android:textColor="#000000" />
<TextView
android:text="Logout"
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:id="@+id/logout"
android:layout_marginRight="5dp"
android:elevation="8dp"
android:textColor="#000000" />
</Toolbar>
</LinearLayout>
它包含在其他 .axml 中
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:minWidth="25px"
android:minHeight="25px"
android:background="#fafafa"
android:weightSum="100">
<!--Toolbar was called from here by include-->
<include
layout="@layout/ToolbarLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<LinearLayout
android:orientation="horizontal"
android:minWidth="25px"
android:minHeight="25px"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/olive"
android:id="@+id/linearLayout1"
android:padding="5dp">
<ImageButton
android:src="@drawable/backB"
android:layout_width="30dp"
android:layout_height="30dp"
android:background="@color/olive"
android:id="@+id/backButton"
android:scaleType="fitCenter" />
<LinearLayout
android:orientation="vertical"
android:minWidth="25px"
android:minHeight="25px"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/linearLayout3"
android:layout_marginLeft="-30dp">
<TextView
android:text="My Orders"
android:textAppearance="? android:attr/textAppearanceLarge"
android:textColor="@color/white"
android:id="@+id/textView1"
android:layout_gravity="center"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
</LinearLayout>
<!--Other codes are not related anymore to the issue-->
</LinearLayout>
我研究了很多,但我认为有关 InflateException 的其他问题与我的问题无关。 我应该在这里解决什么问题?
【问题讨论】:
-
请更新整个 logcat 以便更好地分析。
-
我猜这可能是因为您扩展了活动。试试stackoverflow.com/a/33727136/6212404
标签: android xml xamarin.android