为什么?attr/colorAccent在棒棒糖版本以下不起作用? [英] Why ?attr/colorAccent dose not work below lollipop version?

查看:132
本文介绍了为什么?attr/colorAccent在棒棒糖版本以下不起作用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已将主题添加到我的应用程序中.为此,我使用了多种强调色来添加图像按钮.我有一个名为fab选择器xml的xml文件,该文件为图像按钮提供了形状和颜色.但是该文件有例外.

I have added themes to my application. For this I have used multiple accent colors to add on image button. I have a xml file named fab selector xml , which gives shape and color to image button. But its giving exceptions on this file.

第一个异常是类图像按钮的inflateException. 第二个是找不到资源fab选择器异常. Fab选择器位于可绘制文件夹中.

1st exception is inflateException for class image button. 2nd is resource not found Exception for fab selector. Fab selector resides in drawable folder.

它还会显示,",原因:java.lang.UnsupportedOperationException:无法转换为颜色:type = 0x2

Its also showing ,, Caused by: java.lang.UnsupportedOperationException: Can't convert to color: type=0x2

如果我使用<solid android:color="?attr/colorAccent" />

?attr/colorAccent,如果我使用它,效果很好

?attr/colorAccent and it works fine if I use

 <solid android:color="@color/colorAccent"> 

因为它给出十六进制颜色值.

as it gives hex color value.

奇怪的是,我将其应用于工具栏的方式也是如此,它也可以在棒棒糖以下使用.唯一的例外是在fab选择器文件上.

The strange thing same way I have applied this to toolbar and it works below lollipop as well. Only it's giving exception on fab selector file.

我不知道该如何克服?

Fab选择器

    <?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">

    <item android:state_pressed="true">
        <shape android:shape="oval">
            <solid android:color="?attr/colorAccent" />
        </shape>
    </item>

    <item android:state_focused="true">
        <shape android:shape="oval">
            <solid android:color="?attr/colorAccent" />
        </shape>
    </item>

    <item>
        <shape android:shape="oval">
            <solid android:color="?attr/colorAccent" />
        </shape>
    </item>

</selector>

日志:

2800/com.example.siddhi.timetablelayout E/AndroidRuntime:FATAL 例外:主要 02-18 05:11:01.161 2800-2800/com.example.siddhi.timetablelayout E/AndroidRuntime:java.lang.RuntimeException:无法启动活动 ComponentInfo {com.example.siddhi.timetablelayout/com.example.siddhi.timetablelayout.MainActivity}: android.view.InflateException:二进制XML文件第16行:错误 膨胀类ImageButton 02-18 05:11:01.161 2800-2800/com.example.siddhi.timetablelayout E/AndroidRuntime:at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2059) 02-18 05:11:01.161 2800-2800/com.example.siddhi.timetablelayout E/AndroidRuntime:at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084) 02-18 05:11:01.161 2800-2800/com.example.siddhi.timetablelayout E/AndroidRuntime:at android.app.ActivityThread.access $ 600(ActivityThread.java:130) 02-18 05:11:01.161 2800-2800/com.example.siddhi.timetablelayout E/AndroidRuntime:at android.app.ActivityThread $ H.handleMessage(ActivityThread.java:1195) 02-18 05:11:01.161 2800-2800/com.example.siddhi.timetablelayout E/AndroidRuntime:at android.os.Handler.dispatchMessage(Handler.java:99) 02-18 05:11:01.161 2800-2800/com.example.siddhi.timetablelayout E/AndroidRuntime:at android.os.Looper.loop(Looper.java:137) 02-18 05:11:01.161 2800-2800/com.example.siddhi.timetablelayout E/AndroidRuntime:at android.app.ActivityThread.main(ActivityThread.java:4745) 02-18 05:11:01.161 2800-2800/com.example.siddhi.timetablelayout E/AndroidRuntime:at java.lang.reflect.Method.invokeNative(Native 方法) 02-18 05:11:01.161 2800-2800/com.example.siddhi.timetablelayout E/AndroidRuntime:at java.lang.reflect.Method.invoke(Method.java:511) 02-18 05:11:01.161 2800-2800/com.example.siddhi.timetablelayout E/AndroidRuntime:at com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:786) 02-18 05:11:01.161 2800-2800/com.example.siddhi.timetablelayout E/AndroidRuntime:at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553) 02-18 05:11:01.161 2800-2800/com.example.siddhi.timetablelayout E/AndroidRuntime:在dalvik.system.NativeStart.main(本机方法) 02-18 05:11:01.161 2800-2800/com.example.siddhi.timetablelayout E/AndroidRuntime:造成原因:android.view.InflateException:二进制 XML文件第16行:膨胀类ImageButton时出错 02-18 05:11:01.161 2800-2800/com.example.siddhi.timetablelayout E/AndroidRuntime:at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704) 02-18 05:11:01.161 2800-2800/com.example.siddhi.timetablelayout E/AndroidRuntime:at android.view.LayoutInflater.rInflate(LayoutInflater.java:746) 02-18 05:11:01.161 2800-2800/com.example.siddhi.timetablelayout E/AndroidRuntime:at android.view.LayoutInflater.parseInclude(LayoutInflater.java:830) 02-18 05:11:01.161 2800-2800/com.example.siddhi.timetablelayout E/AndroidRuntime:at android.view.LayoutInflater.rInflate(LayoutInflater.java:736) 02-18 05:11:01.161 2800-2800/com.example.siddhi.timetablelayout E/AndroidRuntime:at android.view.LayoutInflater.rInflate(LayoutInflater.java:749) 02-18 05:11:01.161 2800-2800/com.example.siddhi.timetablelayout E/AndroidRuntime:at android.view.LayoutInflater.rInflate(LayoutInflater.java:749) 02-18 05:11:01.161 2800-2800/com.example.siddhi.timetablelayout E/AndroidRuntime:at android.view.LayoutInflater.inflate(LayoutInflater.java:489) 02-18 05:11:01.161 2800-2800/com.example.siddhi.timetablelayout E/AndroidRuntime:at android.view.LayoutInflater.inflate(LayoutInflater.java:396) 02-18 05:11:01.161 2800-2800/com.example.siddhi.timetablelayout E/AndroidRuntime:at com.example.siddhi.timetablelayout.MainFragment.onCreateView(MainFragment.java:33) 02-18 05:11:01.161 2800-2800/com.example.siddhi.timetablelayout E/AndroidRuntime:at android.support.v4.app.Fragment.performCreateView(Fragment.java:1962) 02-18 05:11:01.161 2800-2800/com.example.siddhi.timetablelayout E/AndroidRuntime:at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1067) 02-18 05:11:01.161 2800-2800/com.example.siddhi.timetablelayout E/AndroidRuntime:at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1248) 02-18 05:11:01.161 2800-2800/com.example.siddhi.timetablelayout E/AndroidRuntime:at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:738) 02-18 05:11:01.161 2800-2800/com.example.siddhi.timetablelayout E/AndroidRuntime:at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1613) 02-18 05:11:01.161 2800-2800/com.example.siddhi.timetablelayout E/AndroidRuntime:at android.support.v4.app.FragmentController.execPendingActions(FragmentController.java:330) 02-18 05:11:01.161 2800-2800/com.example.siddhi.timetablelayout E/AndroidRuntime:at android.support.v4.app.FragmentActivity.onStart(FragmentActivity.java:547) 02-18 05:11:01.161 2800-2800/com.example.siddhi.timetablelayout E/AndroidRuntime:at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1163) 02-18 05:11:01.161 2800-2800/com.example.siddhi.timetablelayout E/AndroidRuntime:at android.app.Activity.performStart(Activity.java:5018) 02-18 05:11:01.161 2800-2800/com.example.siddhi.timetablelayout E/AndroidRuntime:at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2032) 02-18 05:11:01.161 2800-2800/com.example.siddhi.timetablelayout E/AndroidRuntime:at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084) 02-18 05:11:01.161 2800-2800/com.example.siddhi.timetablelayout E/AndroidRuntime:at android.app.ActivityThread.access $ 600(ActivityThread.java:130) 02-18 05:11:01.161 2800-2800/com.example.siddhi.timetablelayout E/AndroidRuntime:at android.app.ActivityThread $ H.handleMessage(ActivityThread.java:1195) 02-18 05:11:01.161 2800-2800/com.example.siddhi.timetablelayout E/AndroidRuntime:at android.os.Handler.dispatchMessage(Handler.java:99) 02-18 05:11:01.161 2800-2800/com.example.siddhi.timetablelayout E/AndroidRuntime:at android.os.Looper.loop(Looper.java:137) 02-18 05:11:01.161 2800-2800/com.example.siddhi.timetablelayout E/AndroidRuntime:at android.app.ActivityThread.main(ActivityThread.java:4745) 02-18 05:11:01.161 2800-2800/com.example.siddhi.timetablelayout E/AndroidRuntime:at java.lang.reflect.Method.invokeNative(Native 方法) 02-18 05:11:01.161 2800-2800/com.example.siddhi.timetablelayout E/AndroidRuntime:at java.lang.reflect.Method.invoke(Method.java:511) 02-18 05:11:01.161 2800-2800/com.example.siddhi.timetablelayout E/AndroidRuntime:at com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:786) 02-18 05:11:01.161 2800-2800/com.example.siddhi.timetablelayout E/AndroidRuntime:at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553) 02-18 05:11:01.161 2800-2800/com.example.siddhi.timetablelayout E/AndroidRuntime:at dalvik.system.NativeStart.main(Native 方法) 02-18 05:11:01.161 2800-2800/com.example.siddhi.timetablelayout E/AndroidRuntime:由以下原因引起: android.content.res.Resources $ NotFoundException:文件 可绘制资源ID#0x7f020081中的res/drawable/fab_selector.xml 02-18 05:11:01.161 2800-2800/com.example.siddhi.timetablelayout E/AndroidRuntime:at android.content.res.Resources.loadDrawable(Resources.java:1918) 02-18 05:11:01.161 2800-2800/com.example.siddhi.timetablelayout E/AndroidRuntime:at android.content.res.TypedArray.getDrawable(TypedArray.java:601) 02-18 05:11:01.161 2800-2800/com.example.siddhi.timetablelayout E/AndroidRuntime:位于android.view.View.(View.java:3336) 02-18 05:11:01.161 2800-2800/com.example.siddhi.timetablelayout E/AndroidRuntime:at android.widget.ImageView.(ImageView.java:114) 02-18 05:11:01.161 2800-2800/com.example.siddhi.timetablelayout E/AndroidRuntime:at android.widget.ImageButton.(ImageButton.java:87) 02-18 05:11:01.161 2800-2800/com.example.siddhi.timetablelayout E/AndroidRuntime:at android.support.v7.widget.AppCompatImageButton.(AppCompatImageButton.java:59) 02-18 05:11:01.161 2800-2800/com.example.siddhi.timetablelayout E/AndroidRuntime:at android.support.v7.widget.AppCompatImageButton.(AppCompatImageButton.java:55) 02-18 05:11:01.161 2800-2800/com.example.siddhi.timetablelayout E/AndroidRuntime:at android.support.v7.app.AppCompatViewInflater.createView(AppCompatViewInflater.java:107) 02-18 05:11:01.161 2800-2800/com.example.siddhi.timetablelayout E/AndroidRuntime:at android.support.v7.app.AppCompatDelegateImplV7.createView(AppCompatDelegateImplV7.java:938) 02-18 05:11:01.161 2800-2800/com.example.siddhi.timetablelayout E/AndroidRuntime:at android.support.v7.app.AppCompatDelegateImplV7.onCreateView(AppCompatDelegateImplV7.java:992) 02-18 05:11:01.161 2800-2800/com.example.siddhi.timetablelayout E/AndroidRuntime:at android.support.v4.view.LayoutInflaterCompatHC $ FactoryWrapperHC.onCreateView(LayoutInflaterCompatHC.java:44) 02-18 05:11:01.161 2800-2800/com.example.siddhi.timetablelayout E/AndroidRuntime:at android.view.LayoutInflater $ FactoryMerger.onCreateView(LayoutInflater.java:171) 02-18 05:11:01.161 2800-2800/com.example.siddhi.timetablelayout E/AndroidRuntime:at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:675) 02-18 05:11:01.161 2800-2800/com.example.siddhi.timetablelayout E/AndroidRuntime:at android.view.LayoutInflater.rInflate(LayoutInflater.java:746) 02-18 05:11:01.161 2800-2800/com.example.siddhi.timetablelayout E/AndroidRuntime:at android.view.LayoutInflater.parseInclude(LayoutInflater.java:830) 02-18 05:11:01.161 2800-2800/com.example.siddhi.timetablelayout E/AndroidRuntime:at android.view.LayoutInflater.rInflate(LayoutInflater.java:736) 02-18 05:11:01.161 2800-2800/com.example.siddhi.timetablelayout E/AndroidRuntime:at android.view.LayoutInflater.rInflate(LayoutInflater.java:749) 02-18 05:11:01.161 2800-2800/com.example.siddhi.timetablelayout E/AndroidRuntime:at android.view.LayoutInflater.rInflate(LayoutInflater.java:749) 02-18 05:11:01.161 2800-2800/com.example.siddhi.timetablelayout E/AndroidRuntime:at android.view.LayoutInflater.inflate(LayoutInflater.java:489) 02-18 05:11:01.161 2800-2800/com.example.siddhi.timetablelayout E/AndroidRuntime:at android.view.LayoutInflater.inflate(LayoutInflater.java:396) 02-18 05:11:01.161 2800-2800/com.example.siddhi.timetablelayout E/AndroidRuntime:at com.example.siddhi.timetablelayout.MainFragment.onCreateView(MainFragment.java:33) 02-18 05:11:01.161 2800-2800/com.example.siddhi.timetablelayout E/AndroidRuntime:at android.support.v4.app.Fragment.performCreateView(Fragment.java:1962) 02-18 05:11:01.161 2800-2800/com.example.siddhi.timetablelayout E/AndroidRuntime:at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1067) 02-18 05:11:01.161 2800-2800/com.example.siddhi.timetablelayout E/AndroidRuntime:at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1248) 02-18 05:11:01.161 2800-2800/com.example.siddhi.timetablelayout E/AndroidRuntime:at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:738) 02-18 05:11:01.161 2800-2800/com.example.siddhi.timetablelayout E/AndroidRuntime:at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1613) 02-18 05:11:01.161 2800-2800/com.example.siddhi.timetablelayout E/AndroidRuntime:at android.support.v4.app.FragmentController.execPendingActions(FragmentController.java:330) 02-18 05:11:01.161 2800-2800/com.example.siddhi.timetablelayout E/AndroidRuntime:at android.support.v4.app.FragmentActivity.onStart(FragmentActivity.java:547) 02-18 05:11:01.161 2800-2800/com.example.siddhi.timetablelayout E/AndroidRuntime:at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1163) 02-18 05:11:01.161 2800-2800/com.example.siddhi.timetablelayout E/AndroidRuntime:at android.app.Activity.performStart(Activity.java:5018) 02-18 05:11:01.161 2800-2800/com.example.siddhi.timetablelayout E/AndroidRuntime:at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2032) 02-18 05:11:01.161 2800-2800/com.example.siddhi.timetablelayout E/AndroidRuntime:at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084) 02-18 05:11:01.161 2800-2800/com.example.siddhi.timetablelayout E/AndroidRuntime:at android.app.ActivityThread.access $ 600(ActivityThread.java:130) 02-18 05:11:01.161 2800-2800/com.example.siddhi.timetablelayout E/AndroidRuntime:at android.app.ActivityThread $ H.handleMessage(ActivityThread.java:1195) 02-18 05:11:01.161 2800-2800/com.example.siddhi.timetablelayout E/AndroidRuntime:at android.os.Handler.dispatchMessage(Handler.java:99) 02-18 05:11:01.161 2800-2800/com.example.siddhi.timetablelayout E/AndroidRuntime:at android.os.Looper.loop(Looper.java:137) 02-18 05:11:01.161 2800-2800/com.example.siddhi.timetablelayout E/AndroidRuntime:at android.app.ActivityThread.main(ActivityThread.java:4745) 02-18 05:11:01.161 2800-2800/com.example.siddhi.timetablelayout E/AndroidRuntime:at java.lang.reflect.Method.invokeNative(Native 方法) 02-18 05:11:01.161 2800-2800/com.example.siddhi.timetablelayout E/AndroidRuntime:at java.lang.reflect.Method.invoke(Method.java:511) 02-18 05:11:01.161 2800-2800/com.example.siddhi.timetablelayout E/AndroidRuntime:at com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:786) 02-18 05:11:01.161 2800-2800/com.example.siddhi.timetablelayout E/AndroidRuntime:at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553) 02-18 05:11:01.161 2800-2800/com.example.siddhi.timetablelayout E/AndroidRuntime:at dalvik.system.NativeStart.main(Native 方法) 02-18 05:11:01.161 2800-2800/com.example.siddhi.timetablelayout E/AndroidRuntime:造成原因:java.lang.UnsupportedOperationException: 无法转换为颜色:类型= 0x2 02-18 05:11:01.161 2800-2800/com.example.siddhi.timetablelayout E/AndroidRuntime:at android.content.res.TypedArray.getColor(TypedArray.java:326) 02-18 05:11:01.161 2800-2800/com.example.siddhi.timetablelayout E/AndroidRuntime:at android.graphics.drawable.GradientDrawable.inflate(GradientDrawable.java:951) 02-18 05:11:01.161 2800-2800/com.example.siddhi.timetablelayout E/AndroidRuntime:at android.graphics.drawable.Drawable.createFromXmlInner(Drawable.java:881)

2800/com.example.siddhi.timetablelayout E/AndroidRuntime: FATAL EXCEPTION: main 02-18 05:11:01.161 2800-2800/com.example.siddhi.timetablelayout E/AndroidRuntime: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.siddhi.timetablelayout/com.example.siddhi.timetablelayout.MainActivity}: android.view.InflateException: Binary XML file line #16: Error inflating class ImageButton 02-18 05:11:01.161 2800-2800/com.example.siddhi.timetablelayout E/AndroidRuntime: at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2059) 02-18 05:11:01.161 2800-2800/com.example.siddhi.timetablelayout E/AndroidRuntime: at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084) 02-18 05:11:01.161 2800-2800/com.example.siddhi.timetablelayout E/AndroidRuntime: at android.app.ActivityThread.access$600(ActivityThread.java:130) 02-18 05:11:01.161 2800-2800/com.example.siddhi.timetablelayout E/AndroidRuntime: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195) 02-18 05:11:01.161 2800-2800/com.example.siddhi.timetablelayout E/AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:99) 02-18 05:11:01.161 2800-2800/com.example.siddhi.timetablelayout E/AndroidRuntime: at android.os.Looper.loop(Looper.java:137) 02-18 05:11:01.161 2800-2800/com.example.siddhi.timetablelayout E/AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:4745) 02-18 05:11:01.161 2800-2800/com.example.siddhi.timetablelayout E/AndroidRuntime: at java.lang.reflect.Method.invokeNative(Native Method) 02-18 05:11:01.161 2800-2800/com.example.siddhi.timetablelayout E/AndroidRuntime: at java.lang.reflect.Method.invoke(Method.java:511) 02-18 05:11:01.161 2800-2800/com.example.siddhi.timetablelayout E/AndroidRuntime: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786) 02-18 05:11:01.161 2800-2800/com.example.siddhi.timetablelayout E/AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553) 02-18 05:11:01.161 2800-2800/com.example.siddhi.timetablelayout E/AndroidRuntime: at dalvik.system.NativeStart.main(Native Method) 02-18 05:11:01.161 2800-2800/com.example.siddhi.timetablelayout E/AndroidRuntime: Caused by: android.view.InflateException: Binary XML file line #16: Error inflating class ImageButton 02-18 05:11:01.161 2800-2800/com.example.siddhi.timetablelayout E/AndroidRuntime: at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704) 02-18 05:11:01.161 2800-2800/com.example.siddhi.timetablelayout E/AndroidRuntime: at android.view.LayoutInflater.rInflate(LayoutInflater.java:746) 02-18 05:11:01.161 2800-2800/com.example.siddhi.timetablelayout E/AndroidRuntime: at android.view.LayoutInflater.parseInclude(LayoutInflater.java:830) 02-18 05:11:01.161 2800-2800/com.example.siddhi.timetablelayout E/AndroidRuntime: at android.view.LayoutInflater.rInflate(LayoutInflater.java:736) 02-18 05:11:01.161 2800-2800/com.example.siddhi.timetablelayout E/AndroidRuntime: at android.view.LayoutInflater.rInflate(LayoutInflater.java:749) 02-18 05:11:01.161 2800-2800/com.example.siddhi.timetablelayout E/AndroidRuntime: at android.view.LayoutInflater.rInflate(LayoutInflater.java:749) 02-18 05:11:01.161 2800-2800/com.example.siddhi.timetablelayout E/AndroidRuntime: at android.view.LayoutInflater.inflate(LayoutInflater.java:489) 02-18 05:11:01.161 2800-2800/com.example.siddhi.timetablelayout E/AndroidRuntime: at android.view.LayoutInflater.inflate(LayoutInflater.java:396) 02-18 05:11:01.161 2800-2800/com.example.siddhi.timetablelayout E/AndroidRuntime: at com.example.siddhi.timetablelayout.MainFragment.onCreateView(MainFragment.java:33) 02-18 05:11:01.161 2800-2800/com.example.siddhi.timetablelayout E/AndroidRuntime: at android.support.v4.app.Fragment.performCreateView(Fragment.java:1962) 02-18 05:11:01.161 2800-2800/com.example.siddhi.timetablelayout E/AndroidRuntime: at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1067) 02-18 05:11:01.161 2800-2800/com.example.siddhi.timetablelayout E/AndroidRuntime: at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1248) 02-18 05:11:01.161 2800-2800/com.example.siddhi.timetablelayout E/AndroidRuntime: at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:738) 02-18 05:11:01.161 2800-2800/com.example.siddhi.timetablelayout E/AndroidRuntime: at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1613) 02-18 05:11:01.161 2800-2800/com.example.siddhi.timetablelayout E/AndroidRuntime: at android.support.v4.app.FragmentController.execPendingActions(FragmentController.java:330) 02-18 05:11:01.161 2800-2800/com.example.siddhi.timetablelayout E/AndroidRuntime: at android.support.v4.app.FragmentActivity.onStart(FragmentActivity.java:547) 02-18 05:11:01.161 2800-2800/com.example.siddhi.timetablelayout E/AndroidRuntime: at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1163) 02-18 05:11:01.161 2800-2800/com.example.siddhi.timetablelayout E/AndroidRuntime: at android.app.Activity.performStart(Activity.java:5018) 02-18 05:11:01.161 2800-2800/com.example.siddhi.timetablelayout E/AndroidRuntime: at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2032) 02-18 05:11:01.161 2800-2800/com.example.siddhi.timetablelayout E/AndroidRuntime: at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)  02-18 05:11:01.161 2800-2800/com.example.siddhi.timetablelayout E/AndroidRuntime: at android.app.ActivityThread.access$600(ActivityThread.java:130)  02-18 05:11:01.161 2800-2800/com.example.siddhi.timetablelayout E/AndroidRuntime: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)  02-18 05:11:01.161 2800-2800/com.example.siddhi.timetablelayout E/AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:99)  02-18 05:11:01.161 2800-2800/com.example.siddhi.timetablelayout E/AndroidRuntime: at android.os.Looper.loop(Looper.java:137)  02-18 05:11:01.161 2800-2800/com.example.siddhi.timetablelayout E/AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:4745)  02-18 05:11:01.161 2800-2800/com.example.siddhi.timetablelayout E/AndroidRuntime: at java.lang.reflect.Method.invokeNative(Native Method)  02-18 05:11:01.161 2800-2800/com.example.siddhi.timetablelayout E/AndroidRuntime: at java.lang.reflect.Method.invoke(Method.java:511)  02-18 05:11:01.161 2800-2800/com.example.siddhi.timetablelayout E/AndroidRuntime: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)  02-18 05:11:01.161 2800-2800/com.example.siddhi.timetablelayout E/AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)  02-18 05:11:01.161 2800-2800/com.example.siddhi.timetablelayout E/AndroidRuntime: at dalvik.system.NativeStart.main(Native Method)  02-18 05:11:01.161 2800-2800/com.example.siddhi.timetablelayout E/AndroidRuntime: Caused by: android.content.res.Resources$NotFoundException: File res/drawable/fab_selector.xml from drawable resource ID #0x7f020081 02-18 05:11:01.161 2800-2800/com.example.siddhi.timetablelayout E/AndroidRuntime: at android.content.res.Resources.loadDrawable(Resources.java:1918) 02-18 05:11:01.161 2800-2800/com.example.siddhi.timetablelayout E/AndroidRuntime: at android.content.res.TypedArray.getDrawable(TypedArray.java:601) 02-18 05:11:01.161 2800-2800/com.example.siddhi.timetablelayout E/AndroidRuntime: at android.view.View.(View.java:3336) 02-18 05:11:01.161 2800-2800/com.example.siddhi.timetablelayout E/AndroidRuntime: at android.widget.ImageView.(ImageView.java:114) 02-18 05:11:01.161 2800-2800/com.example.siddhi.timetablelayout E/AndroidRuntime: at android.widget.ImageButton.(ImageButton.java:87) 02-18 05:11:01.161 2800-2800/com.example.siddhi.timetablelayout E/AndroidRuntime: at android.support.v7.widget.AppCompatImageButton.(AppCompatImageButton.java:59) 02-18 05:11:01.161 2800-2800/com.example.siddhi.timetablelayout E/AndroidRuntime: at android.support.v7.widget.AppCompatImageButton.(AppCompatImageButton.java:55) 02-18 05:11:01.161 2800-2800/com.example.siddhi.timetablelayout E/AndroidRuntime: at android.support.v7.app.AppCompatViewInflater.createView(AppCompatViewInflater.java:107) 02-18 05:11:01.161 2800-2800/com.example.siddhi.timetablelayout E/AndroidRuntime: at android.support.v7.app.AppCompatDelegateImplV7.createView(AppCompatDelegateImplV7.java:938) 02-18 05:11:01.161 2800-2800/com.example.siddhi.timetablelayout E/AndroidRuntime: at android.support.v7.app.AppCompatDelegateImplV7.onCreateView(AppCompatDelegateImplV7.java:992) 02-18 05:11:01.161 2800-2800/com.example.siddhi.timetablelayout E/AndroidRuntime: at android.support.v4.view.LayoutInflaterCompatHC$FactoryWrapperHC.onCreateView(LayoutInflaterCompatHC.java:44) 02-18 05:11:01.161 2800-2800/com.example.siddhi.timetablelayout E/AndroidRuntime: at android.view.LayoutInflater$FactoryMerger.onCreateView(LayoutInflater.java:171) 02-18 05:11:01.161 2800-2800/com.example.siddhi.timetablelayout E/AndroidRuntime: at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:675) 02-18 05:11:01.161 2800-2800/com.example.siddhi.timetablelayout E/AndroidRuntime: at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)  02-18 05:11:01.161 2800-2800/com.example.siddhi.timetablelayout E/AndroidRuntime: at android.view.LayoutInflater.parseInclude(LayoutInflater.java:830)  02-18 05:11:01.161 2800-2800/com.example.siddhi.timetablelayout E/AndroidRuntime: at android.view.LayoutInflater.rInflate(LayoutInflater.java:736)  02-18 05:11:01.161 2800-2800/com.example.siddhi.timetablelayout E/AndroidRuntime: at android.view.LayoutInflater.rInflate(LayoutInflater.java:749)  02-18 05:11:01.161 2800-2800/com.example.siddhi.timetablelayout E/AndroidRuntime: at android.view.LayoutInflater.rInflate(LayoutInflater.java:749)  02-18 05:11:01.161 2800-2800/com.example.siddhi.timetablelayout E/AndroidRuntime: at android.view.LayoutInflater.inflate(LayoutInflater.java:489)  02-18 05:11:01.161 2800-2800/com.example.siddhi.timetablelayout E/AndroidRuntime: at android.view.LayoutInflater.inflate(LayoutInflater.java:396)  02-18 05:11:01.161 2800-2800/com.example.siddhi.timetablelayout E/AndroidRuntime: at com.example.siddhi.timetablelayout.MainFragment.onCreateView(MainFragment.java:33)  02-18 05:11:01.161 2800-2800/com.example.siddhi.timetablelayout E/AndroidRuntime: at android.support.v4.app.Fragment.performCreateView(Fragment.java:1962)  02-18 05:11:01.161 2800-2800/com.example.siddhi.timetablelayout E/AndroidRuntime: at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1067)  02-18 05:11:01.161 2800-2800/com.example.siddhi.timetablelayout E/AndroidRuntime: at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1248)  02-18 05:11:01.161 2800-2800/com.example.siddhi.timetablelayout E/AndroidRuntime: at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:738)  02-18 05:11:01.161 2800-2800/com.example.siddhi.timetablelayout E/AndroidRuntime: at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1613)  02-18 05:11:01.161 2800-2800/com.example.siddhi.timetablelayout E/AndroidRuntime: at android.support.v4.app.FragmentController.execPendingActions(FragmentController.java:330)  02-18 05:11:01.161 2800-2800/com.example.siddhi.timetablelayout E/AndroidRuntime: at android.support.v4.app.FragmentActivity.onStart(FragmentActivity.java:547)  02-18 05:11:01.161 2800-2800/com.example.siddhi.timetablelayout E/AndroidRuntime: at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1163)  02-18 05:11:01.161 2800-2800/com.example.siddhi.timetablelayout E/AndroidRuntime: at android.app.Activity.performStart(Activity.java:5018)  02-18 05:11:01.161 2800-2800/com.example.siddhi.timetablelayout E/AndroidRuntime: at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2032)  02-18 05:11:01.161 2800-2800/com.example.siddhi.timetablelayout E/AndroidRuntime: at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)  02-18 05:11:01.161 2800-2800/com.example.siddhi.timetablelayout E/AndroidRuntime: at android.app.ActivityThread.access$600(ActivityThread.java:130)  02-18 05:11:01.161 2800-2800/com.example.siddhi.timetablelayout E/AndroidRuntime: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)  02-18 05:11:01.161 2800-2800/com.example.siddhi.timetablelayout E/AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:99)  02-18 05:11:01.161 2800-2800/com.example.siddhi.timetablelayout E/AndroidRuntime: at android.os.Looper.loop(Looper.java:137)  02-18 05:11:01.161 2800-2800/com.example.siddhi.timetablelayout E/AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:4745)  02-18 05:11:01.161 2800-2800/com.example.siddhi.timetablelayout E/AndroidRuntime: at java.lang.reflect.Method.invokeNative(Native Method)  02-18 05:11:01.161 2800-2800/com.example.siddhi.timetablelayout E/AndroidRuntime: at java.lang.reflect.Method.invoke(Method.java:511)  02-18 05:11:01.161 2800-2800/com.example.siddhi.timetablelayout E/AndroidRuntime: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)  02-18 05:11:01.161 2800-2800/com.example.siddhi.timetablelayout E/AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)  02-18 05:11:01.161 2800-2800/com.example.siddhi.timetablelayout E/AndroidRuntime: at dalvik.system.NativeStart.main(Native Method)  02-18 05:11:01.161 2800-2800/com.example.siddhi.timetablelayout E/AndroidRuntime: Caused by: java.lang.UnsupportedOperationException: Can't convert to color: type=0x2 02-18 05:11:01.161 2800-2800/com.example.siddhi.timetablelayout E/AndroidRuntime: at android.content.res.TypedArray.getColor(TypedArray.java:326) 02-18 05:11:01.161 2800-2800/com.example.siddhi.timetablelayout E/AndroidRuntime: at android.graphics.drawable.GradientDrawable.inflate(GradientDrawable.java:951) 02-18 05:11:01.161 2800-2800/com.example.siddhi.timetablelayout E/AndroidRuntime: at android.graphics.drawable.Drawable.createFromXmlInner(Drawable.java:881)

我在style.xml中提到了colorAccent

I have mentioned colorAccent in style.xml

 <!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
    <!-- Customize your theme here. -->
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
    <item name="android:textColorSecondary">@color/white</item>
    <item name="windowActionBarOverlay">false</item>

    <item name="windowActionBar">false</item>

    <item name="windowNoTitle">true</item>
    <item name="android:windowBackground">@color/background_material_light</item>
</style>

该怎么办?谢谢你.

推荐答案

您尝试执行的操作仅适用于Android级别> = 21.

What you are trying to do only works for Android level >=21.

请参见此处:支持在可绘制XML中引用主题属性

从我读到的内容来看,这是一个错误... 您可以在此处此处.

From what I read it was a bug... You can read some more on this problem here or here.

这篇关于为什么?attr/colorAccent在棒棒糖版本以下不起作用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆