我在编辑其中一个xaml文件后加载supprt.v7.toolbar时收到IllegalArgumentException。
以下是编译器告诉我的内容
Creating class loader with 0 projects
Creating LibraryClassLoader in shadow copy path C:\Users\konno\AppData\Local\Temp\AndroidDesignerJars180644833948983183
Trying to load class android.support.v7.widget.Toolbar
mono.android.DesignerException: java.lang.IllegalArgumentException
at mono.android.DesignerException.fromThrowable(DesignerException.java:46)
at mono.android.DesignerSession.checkRenderResultForError(DesignerSession.java:187)
at mono.android.DesignerSession.load(DesignerSession.java:239)
at mono.android.DesignerSession.processMessage(DesignerSession.java:704)
at mono.android.MessageListener.executeMessage(MessageListener.java:88)
at mono.android.MessageListener$Runner.run(MessageListener.java:44)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.IllegalArgumentException: column indices (start + span) mustn't exceed the column count.
at android.widget.GridLayout.handleInvalidParams(GridLayout.java:823)
at android.widget.GridLayout.checkLayoutParams(GridLayout.java:837)
at android.widget.GridLayout.checkLayoutParams(GridLayout.java:853)
at android.view.ViewGroup.addViewInner(ViewGroup.java:4462)
at android.view.ViewGroup.addView(ViewGroup.java:4295)
at android.view.ViewGroup.addView(ViewGroup.java:4267)
at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:862)
at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:70)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:834)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821)
at android.view.LayoutInflater.inflate(LayoutInflater.java:518)
at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
at com.android.layoutlib.bridge.impl.RenderSessionImpl.inflate(RenderSessionImpl.java:324)
at com.android.layoutlib.bridge.Bridge.createSession(Bridge.java:429)
at com.android.ide.common.rendering.LayoutLibrary.createSession(LayoutLibrary.java:368)
at mono.android.DesignerSession.load(DesignerSession.java:233)
... 4 more
我对工具栏做的唯一一件事是更改它所在的行。然后在设计师重新打开后,我得到了上面的错误。我尝试删除我添加到工具栏中的代码行,但错误仍然存在。
XAML活动代码
<?xml version="1.0" encoding="utf-8"?>
<GridLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:columnCount="3"
android:rowCount="6">
<!--This is for the Toolbar Only-->
<android.support.v7.widget.Toolbar
android:id="@+id/RestaurantTotalToolbar"
android:minHeight="?android:attr/actionBarSize"
android:layout_row="0"
android:background="@color/colorPrimary"
android:theme="@style/ToolbarStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<!--This is for the Toolbar Only-->
<!--What is the Ticket Total? -->
<TextView
android:text="@string/questTicketTotal"
android:textAppearance="?android:attr/textAppearanceLarge"
android:id="@+id/questTicketTextView"
android:layout_row="1"
android:layout_column="0"
android:layout_columnSpan="3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="fill_horizontal"
android:gravity="center"
android:layout_rowWeight="10" />
<EditText
android:hint="$0.00"
android:id="@+id/ticketTotal"
android:layout_row="2"
android:layout_column="0"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:gravity="center"
android:height="50dp"
android:layout_columnSpan="3"
android:layout_rowWeight="1"
android:translationY="-60dp"
android:maxLength="5"
android:inputType="numberDecimal"
android:maxLines="1" />
<!--What is the name of the Restaurant? -->
<TextView
android:text="@string/questRestaurantName"
android:textAppearance="?android:attr/textAppearanceLarge"
android:id="@+id/restaurantNameTextView"
android:layout_row="3"
android:layout_column="0"
android:layout_columnSpan="3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="fill_horizontal"
android:gravity="center"
android:layout_rowWeight="10"
android:translationY="-35dp" />
<EditText
android:hint="Restaurant Name"
android:id="@+id/restaurantName"
android:layout_row="4"
android:layout_column="0"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:gravity="center"
android:height="50dp"
android:layout_width="wrap_content"
android:layout_columnSpan="3"
android:layout_rowWeight="1"
android:translationY="-100dp"
android:inputType="text"
android:singleLine="true"
android:maxLines="1" />
<Button
android:text="@string/nextButton"
android:id="@+id/calcButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_row="5"
android:layout_column="2"
android:layout_columnSpan="3"
android:layout_gravity="right"
android:layout_marginBottom="5dp"
android:layout_marginRight="5dp" />
</GridLayout>
答案 0 :(得分:0)
工具栏不会导致问题。 'android:layout_columnSpan =“3”'导致了问题,因为按钮是在第2列中设置的,我试图将其跨度设置为3,这是它无法做到的。
对按钮代码的此更改修复了问题
android:layout_column="0"
android:layout_columnSpan="3"