0

我在我的主要活动中添加了一个 ImageView,但是当我运行应用程序时它崩溃并给出一个 Inflate 异常。我从错误日志中看到,为这个活动构建 xml 是一个问题。但我想知道的是什么活动具体错了吗?完整的错误日志发布在这里: http: //pastebin.com/PAYrjHCL

通过查找错误,我认为它可能来自冲突的高度或宽度设置,但我不确定在哪里。主要错误是@第 79 行,它在下面的代码中突出显示。

活动 XML 布局是这样的:

<ScrollView 
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:fillViewport="true"
    android:gravity="center_vertical"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context=".MainActivity"
     >

<RelativeLayout
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical" >

<EditText
    android:id="@+id/ductDepth"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_above="@+id/calc"
    android:layout_centerHorizontal="true"
    android:layout_marginBottom="37dp"
    android:ems="10"
    android:hint="@string/enter_duct_depth_mm"
    android:inputType="numberDecimal"
    android:singleLine="true" >

    <requestFocus />
</EditText>

<EditText
    android:id="@+id/offDepth"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_above="@+id/textView3"
    android:layout_alignLeft="@+id/ductDepth"
    android:layout_marginBottom="14dp"
    android:ems="10"
    android:hint="@string/enter_offset_depth_mm"
    android:inputType="numberDecimal"
    android:singleLine="true" />

<EditText
    android:id="@+id/offLength"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_above="@+id/textView2"
    android:layout_alignLeft="@+id/offDepth"
    android:layout_marginBottom="20dp"
    android:ems="10"
    android:hint="@string/enter_offset_length_mm"
    android:inputType="numberDecimal"
    android:singleLine="true" />

<TextView
    android:id="@+id/textView2"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_above="@+id/offDepth"
    android:layout_alignLeft="@+id/offDepth"
    android:text="Depth:"
    android:textSize="30sp" />

<TextView
    android:id="@+id/textView3"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_above="@+id/ductDepth"
    android:layout_alignLeft="@+id/ductDepth"
    android:text="Duct Depth:"
    android:textSize="30sp" />

<TextView //line 79!
    android:id="@+id/textView1"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_above="@+id/offLength"
    android:layout_alignLeft="@+id/offLength"
    android:text="Length:"
    android:textColor="@style/AppTheme"
    android:textSize="30sp" />

<Button
    android:id="@+id/calc"
    android:layout_width="200dp"
    android:layout_height="70dp"
    android:layout_alignLeft="@+id/ductDepth"
    android:layout_alignParentBottom="true"
    android:layout_marginBottom="30dp"
    android:background="@drawable/calcbttrans" />



<android.support.v4.view.ViewPager     
android:id="@+id/pager"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/calc" >

<!--
This title strip will display the currently visible page title, as well as the page
titles for adjacent pages.
-->

<android.support.v4.view.PagerTitleStrip
    android:id="@+id/pager_title_strip"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_gravity="top"
    android:background="#33b5e5"
    android:paddingBottom="4dp"
    android:paddingTop="4dp"
    android:textColor="#fff" />

</android.support.v4.view.ViewPager>

<ImageView
    android:id="@+id/imageView1"
    android:layout_width="wrap_content"
    android:layout_height="700dp"
    android:layout_above="@+id/textView1"
    android:layout_centerHorizontal="true"
    android:layout_marginBottom="84dp"
    android:src="@drawable/mark3" />

</RelativeLayout>

</ScrollView>
4

2 回答 2

1

android:textColor属性只能传递一个@color 或十六进制值,Android 才能对其进行膨胀。传递一种风格是行不通的。

于 2013-11-14T17:29:40.823 回答
0

你的问题在这里

  android:textColor="@style/AppTheme"

引起:android.content.res.Resources$NotFoundException:资源不是ColorStateList(颜色或路径):

于 2013-11-14T17:31:33.820 回答