遇到错误“二进制XML文件行#0:错误膨胀类”,我是Java新手,非常感谢您的帮助!
这是我的activity_main.xml:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:tools="http://schemas.android.com/tools"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:background="@drawable/back"
tools:context="com.jackmills.urbansportsfitness.MainActivity">
<ImageView
android:id="@+id/btnTraining"
android:layout_centerInParent="true"
android:src="@drawable/play"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<LinearLayout
android:layout_alignParentBottom="true"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_weight="2"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<info.hoang8f.widget.FButton
android:id = "@+id/btnExercises"
android:text="Excercises"
android:textColor="@android:color/white"
android:layout_marginLeft="8dp"
android:layout_marginRight="4dp"
android:layout_weight="1"
android:layout_width = "0dp"
android:layout_height = "wrap_content"
app:buttonColor="@color/colorPrimary"
app:shadowColor="@color/colorPrimaryDark"
app:shadowEnabled="true"
app:shadowHeight="2dp"
app:cornerRadius="2dp"
/>
<info.hoang8f.widget.FButton
android:id = "@+id/btnSetting"
android:text="Settings"
android:textColor="@android:color/white"
android:layout_marginLeft="4dp"
android:layout_marginRight="8dp"
android:layout_weight="1"
android:layout_width = "0dp"
android:layout_height = "wrap_content"
app:buttonColor="@color/colorPrimary"
app:shadowColor="@color/colorPrimaryDark"
app:shadowEnabled="true"
app:shadowHeight="2dp"
app:cornerRadius="2dp"
/>
</LinearLayout>
<info.hoang8f.widget.FButton
android:layout_marginTop="8dp"
android:layout_marginBottom="8dp"
android:id = "@+id/btnCalendar"
android:text="Calendar"
android:textColor="@android:color/white"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_width = "match_parent"
android:layout_height = "wrap_content"
app:buttonColor="@color/colorPrimary"
app:shadowColor="@color/colorPrimaryDark"
app:shadowEnabled="true"
app:shadowHeight="2dp"
app:cornerRadius="0dp"
/>
</LinearLayout>
</RelativeLayout>
这是logcat:
11-30 00:49:29.728 8159-8159/? E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.jackmills.urbansportsfitness, PID: 8159
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.jackmills.urbansportsfitness/com.jackmills.urbansportsfitness.MainActivity}: android.view.InflateException: Binary XML file line #0: Binary XML file line #0: Error inflating class info.hoang8f.widget.FButton
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2778)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2856)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1589)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6494)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
Caused by: android.view.InflateException: Binary XML file line #0: Binary XML file line #0: Error inflating class info.hoang8f.widget.FButton
Caused by: android.view.InflateException: Binary XML file line #0: Error inflating class info.hoang8f.widget.FButton
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.newInstance0(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:334)
at android.view.LayoutInflater.createView(LayoutInflater.java:647)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:790)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:730)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:863)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:866)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:866)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824)
at android.view.LayoutInflater.inflate(LayoutInflater.java:515)
at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
at android.view.LayoutInflater.inflate(LayoutInflater.java:374)
at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:287)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139)
at com.jackmills.urbansportsfitness.MainActivity.onCreate(MainActivity.java:16)
at android.app.Activity.performCreate(Activity.java:7000)
at android.app.Activity.performCreate(Activity.java:6991)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1214)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2731)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2856)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1589)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6494)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
Caused by: java.lang.UnsupportedOperationException: Can't convert value at index 1 to color: type=0x5
at android.content.res.TypedArray.getColor(TypedArray.java:473)
at info.hoang8f.widget.FButton.parseAttrs(FButton.java:116)
at info.hoang8f.widget.FButton.<init>(FButton.java:52)
at java.lang.reflect.Constructor.newInstance0(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:334)
at android.view.LayoutInflater.createView(LayoutInflater.java:647)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:790)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:730)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:863)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:866)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:866)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824)
at android.view.LayoutInflater.inflate(LayoutInflater.java:515)
at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
at android.view.LayoutInflater.inflate(LayoutInflater.java:374)
at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:287)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139)
at com.jackmills.urbansportsfitness.MainActivity.onCreate(MainActivity.java:16)
at android.app.Activity.performCreate(Activity.java:7000)
at android.app.Activity.performCreate(Activity.java:6991)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1214)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2731)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2856)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1589)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6494)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
我试图回滚我的朋友,看看是否有帮助,但无济于事;我想它可能与info.hoang8f.widget.FButton有关,但我不确定它可能是什么。
提前感谢您的帮助!