扩展类TextView时出错

时间:2016-11-17 11:09:55

标签: android

我是Android开发新手,无法解决此构建错误;登录

11-17 11:37:58.520 8894-8894/com.example.android.ocee E/AndroidRuntime: FATAL EXCEPTION: main
                                                                        Process: com.example.android.ocee, PID: 8894
                                                                        java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.android.ocee/com.example.android.ocee.MainActivity}: android.view.InflateException: Binary XML file line #61: Error inflating class TextView
                                                                            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2436)
                                                                            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2498)
                                                                            at android.app.ActivityThread.access$900(ActivityThread.java:179)
                                                                            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1324)
                                                                            at android.os.Handler.dispatchMessage(Handler.java:102)
                                                                            at android.os.Looper.loop(Looper.java:146)
                                                                            at android.app.ActivityThread.main(ActivityThread.java:5641)
                                                                            at java.lang.reflect.Method.invokeNative(Native Method)
                                                                            at java.lang.reflect.Method.invoke(Method.java:515)
                                                                            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1288)
                                                                            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1104)
                                                                            at dalvik.system.NativeStart.main(Native Method)
                                                                         Caused by: android.view.InflateException: Binary XML file line #61: Error inflating class TextView
                                                                            at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:719)
                                                                            at android.view.LayoutInflater.rInflate(LayoutInflater.java:761)
                                                                            at android.view.LayoutInflater.rInflate(LayoutInflater.java:769)
                                                                            at android.view.LayoutInflater.rInflate(LayoutInflater.java:769)
                                                                            at android.view.LayoutInflater.rInflate(LayoutInflater.java:769)
                                                                            at android.view.LayoutInflater.inflate(LayoutInflater.java:498)
                                                                            at android.view.LayoutInflater.inflate(LayoutInflater.java:398)
                                                                            at android.view.LayoutInflater.inflate(LayoutInflater.java:354)
                                                                            at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:276)
                                                                            at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139)
                                                                            at com.example.android.ocee.MainActivity.onCreate(MainActivity.java:11)
                                                                            at android.app.Activity.performCreate(Activity.java:5484)
                                                                            at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1093)
                                                                            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2400)
                                                                            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2498) 
                                                                            at android.app.ActivityThread.access$900(ActivityThread.java:179) 
                                                                            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1324) 
                                                                            at android.os.Handler.dispatchMessage(Handler.java:102) 
                                                                            at android.os.Looper.loop(Looper.java:146) 
                                                                            at android.app.ActivityThread.main(ActivityThread.java:5641) 
                                                                            at java.lang.reflect.Method.invokeNative(Native Method) 
                                                                            at java.lang.reflect.Method.invoke(Method.java:515) 
                                                                            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1288) 
                                                                            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1104) 
                                                                            at dalvik.system.NativeStart.main(Native Method) 
                                                                         Caused by: java.lang.UnsupportedOperationException: Can't convert to dimension: type=0x1
                                                                            at android.content.res.TypedArray.getDimensionPixelSize(TypedArray.java:464)
                                                                            at android.widget.TextView.<init>(TextView.java:1497)
                                                                            at android.support.v7.widget.AppCompatTextView.<init>(AppCompatTextView.java:60)
                                                                            at android.support.v7.widget.AppCompatTextView.<init>(AppCompatTextView.java:56)
                                                                            at android.support.v7.app.AppCompatViewInflater.createView(AppCompatViewInflater.java:103)
                                                                            at android.support.v7.app.AppCompatDelegateImplV7.createView(AppCompatDelegateImplV7.java:972)
                                                                            at android.support.v7.app.AppCompatDelegateImplV7.onCreateView(AppCompatDelegateImplV7.java:1031)
                                                                            at android.support.v4.view.LayoutInflaterCompatHC$FactoryWrapperHC.onCreateView(LayoutInflaterCompatHC.java:44)
                                                                            at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:690)
                                                                            at android.view.LayoutInflater.rInflate(LayoutInflater.java:761) 
                                                                            at android.view.LayoutInflater.rInflate(LayoutInflater.java:769) 
                                                                            at android.view.LayoutInflater.rInflate(LayoutInflater.java:769) 
                                                                            at android.view.LayoutInflater.rInflate(LayoutInflater.java:769) 
                                                                            at android.view.LayoutInflater.inflate(LayoutInflater.java:498) 
                                                                            at android.view.LayoutInflater.inflate(LayoutInflater.java:398) 
                                                                            at android.view.LayoutInflater.inflate(LayoutInflater.java:354) 
                                                                            at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:276) 
                                                                            at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139) 
                                                                            at com.example.android.ocee.MainActivity.onCreate(MainActivity.java:11) 
                                                                            at android.app.Activity.performCreate(Activity.java:5484) 
                                                                            at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1093) 
                                                                            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2400) 
                                                                            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2498) 
                                                                            at android.app.ActivityThread.access$900(ActivityThread.java:179) 
                                                                            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1324) 
                                                                            at android.os.Handler.dispatchMessage(Handler.java:102) 
                                                                            at android.os.Looper.loop(Looper.java:146) 
                                                                            at android.app.ActivityThread.main(ActivityThread.java:5641) 
                                                                            at java.lang.reflect.Method.invokeNative(Native Method) 
                                                                            at java.lang.reflect.Method.invoke(Method.java:515) 
                                                                            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1288) 
                                                                            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1104) 
                                                                            at dalvik.system.NativeStart.main(Native Method)

这是XML文件:avtivity_main.xml

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.android.ocee.MainActivity">

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical">

    <RelativeLayout
        android:id="@+id/real"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <ImageView
            android:id="@+id/img"
            android:src="@drawable/occ"
            android:layout_width="match_parent"
            android:layout_height="165dp"
            android:scaleType="fitCenter"
            android:layout_marginBottom="16dp"/>
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Exclusive Catalogue"
            android:fontFamily="times new roman"
            android:layout_centerHorizontal="true"
            android:textColor="#f4e000"
            android:textSize="18sp"
            android:textStyle="bold"
            android:textAllCaps="true"
            android:layout_marginTop="130dp"
            />
    </RelativeLayout>

    <LinearLayout
        android:id="@+id/linLay2"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:orientation="vertical"
        android:layout_weight="1">

        <LinearLayout
            android:id="@+id/linLay3"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginBottom="16dp"
            android:orientation="horizontal"
            android:background="@android:color/white"
            >

            <ImageView
                android:layout_weight="1"
                android:layout_width="0dp"
                android:layout_height="100dp"
                android:src="@drawable/ocho2"/>

            <TextView
                android:layout_weight="2"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:textSize="?android:textAppearanceMedium"
                android:textColor="@android:color/holo_blue_dark"
                android:text="Dapper Ankara n Jean Shirt"
                />

            <TextView
                android:layout_weight="1"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:textSize="?android:textAppearanceMedium"
                android:textColor="@android:color/black"
                android:text="N6000"/>

        </LinearLayout>

        <LinearLayout
            android:id="@+id/linLay4"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_marginBottom="16dp"
            android:orientation="horizontal"
            android:background="@android:color/white">

            <ImageView
                android:layout_weight="2"
                android:layout_width="0dp"
                android:layout_height="100dp"
                android:src="@drawable/ocho3"/>

            <TextView
                android:layout_weight="2"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:textSize="?android:textAppearanceMedium"
                android:textColor="@android:color/holo_blue_dark"
                android:text="Dope plain white made to fit shirt"/>

            <TextView
                android:layout_weight="1"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:textSize="?android:textAppearanceMedium"
                android:textColor="@android:color/black"
                android:text="N8000"/>

        </LinearLayout>

        <LinearLayout
            android:id="@+id/linLay5"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="horizontal"
            android:background="@android:color/white">

            <ImageView
                android:layout_weight="2"
                android:layout_width="0dp"
                android:layout_height="100dp"
                android:src="@drawable/ocho4"/>

            <TextView
                android:layout_weight="2"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:textSize="?android:textAppearanceMedium"
                android:textColor="@android:color/holo_blue_dark"
                android:text="Vintage Sbyo blend of classic ankara n denim"/>

            <TextView
                android:layout_weight="1"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:textSize="?android:textAppearanceMedium"
                android:textColor="@android:color/black"
                android:text="N7000"/>

        </LinearLayout>

        <LinearLayout
            android:id="@+id/linLay6"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="horizontal"
            android:background="@android:color/white"
            android:layout_marginTop="8dp">

            <ImageView
                android:layout_weight="2"
                android:layout_width="0dp"
                android:layout_height="100dp"
                android:src="@drawable/ocho"/>

            <TextView
                android:layout_weight="2"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:textSize="?android:textAppearanceMedium"
                android:textColor="@android:color/holo_blue_dark"
                android:text="Retro mix of Arztech print and 100% cotton."/>

            <TextView
                android:layout_weight="1"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:textSize="?android:textAppearanceMedium"
                android:textColor="@android:color/black"
                android:text="N7000"/>

        </LinearLayout>

        <LinearLayout
            android:id="@+id/linLay7"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="horizontal"
            android:background="@android:color/white"
            android:layout_marginTop="8dp">

            <ImageView
                android:layout_weight="2"
                android:layout_width="0dp"
                android:layout_height="100dp"
                android:src="@drawable/ochocinco"/>

            <TextView
                android:layout_weight="2"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:textSize="?android:textAppearanceMedium"
                android:textColor="@android:color/holo_blue_dark"
                android:text="Classic Sbyo Ankara on Blue cotton shirt"/>

            <TextView
                android:layout_weight="1"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:textSize="?android:textAppearanceMedium"
                android:textColor="@android:color/black"
                android:text="N9000"/>

        </LinearLayout>

        <LinearLayout
            android:id="@+id/linLay8"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="horizontal"
            android:background="@android:color/white"
            android:layout_marginTop="8dp">

            <ImageView
                android:layout_weight="2"
                android:layout_width="0dp"
                android:layout_height="100dp"
                android:src="@drawable/o"/>

            <TextView
                android:layout_weight="2"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:textSize="?android:textAppearanceMedium"
                android:textColor="@android:color/holo_blue_dark"
                android:text="Classic Sbyo Ankara on Blue cotton shirt"/>

            <TextView
                android:layout_weight="1"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:textSize="?android:textAppearanceMedium"
                android:textColor="@android:color/black"
                android:text="N6000"/>

        </LinearLayout>

</LinearLayout>

我检查了我的视图层次结构,但仍然不明白。请帮助我

1 个答案:

答案 0 :(得分:0)

您能否从xml文件中查看#61的行号,然后删除该行。您可以在textview中添加不受支持的xml标记。