我在我的应用程序中使用Android设计库的浮动操作按钮,它在棒棒糖及以上版本上正常工作但在前棒棒糖版本(4.0-4.2.2)上崩溃了.我真的被困住了,无法弄清楚这个问题.
错误:
FATAL EXCEPTION: main
android.view.InflateException: Binary XML file line #396: Error inflating class android.support.design.widget.FloatingActionButton
at android.view.LayoutInflater.createView(LayoutInflater.java:619)
at
android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:693)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:752)
at android.view.LayoutInflater.inflate(LayoutInflater.java:495)
at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
at
com.example.sony.bluedolphintrialapp.DhampureFragment.onCreateView(DhampureFragment.java:18)
at
android.support.v4.app.Fragment.performCreateView(Fragment.java:1789)
at
android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:955)
android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1138
android.support.v4.app.BackStackRecord.run(BackStackRecord.java:740)android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1501)
android.support.v4.app.FragmentManagerImpl$1.run(FragmentManager.java:458)
at android.os.Handler.handleCallback(Handler.java:725)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5279)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1102)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:869)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.constructNative(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
at android.view.LayoutInflater.createView(LayoutInflater.java:593)
at
android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:693)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:752)
at android.view.LayoutInflater.inflate(LayoutInflater.java:495)
at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
at
com.example.sony.bluedolphintrialapp.DhampureFragment.onCreateView(DhampureFragment.java:18)
at
android.support.v4.app.Fragment.performCreateView(Fragment.java:1789)
at
android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:955)
at
android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1138)
at
android.support.v4.app.BackStackRecord.run(BackStackRecord.java:740)
at
android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1501)
at
android.support.v4.app.FragmentManagerImpl$1.run(FragmentManager.java:458)
at android.os.Handler.handleCallback(Handler.java:725)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5279)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1102)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:869)
at dalvik.system.NativeStart.main(Native Method)
Caused by: android.content.res.Resources$NotFoundException: Resource
is not a ColorStateList (color or path): TypedValue{t=0x1/d=0x7f0b0008
a=-1 r=0x7f0b0008}android.content.res.Resources.loadColorStateList(Resources.java:2963) at
android.content.res.TypedArray.getColorStateList(TypedArray.java:343)
at
android.support.design.widget.FloatingActionButton.(FloatingActionButton.java:8 at
android.support.design.widget.FloatingActionButton.(FloatingActionButton.java:77)
带浮动操作按钮的XML:
而不是
app:rippleColor="@android:color/white"
它应该是
app:rippleColor="@color/white"