8

我有一个应用程序,它有fragmentimage button。问题是它在 5.0 以上工作,5.0但不低于 5.0。最小 sdk 版本是 17。

不明白这里有什么问题。我有 2 个例外。

一是RuntimeExceptionimage button。第二个是ResourceNotFoundException工厂选择器文件。

日志:第一个异常——

java.lang.RuntimeException:无法启动活动 ComponentInfo{com.example.siddhi.timetablelayout/com.example.siddhi.timetablelayout.MainActivity}:android.view.InflateException:二进制 XML 文件第 16 行:

膨胀类错误ImageButton

第二个例外——

引起:android.view.InflateException:二进制 XML 文件第 16 行:膨胀类 ImageButton 时出错

在线的 :

View view = inflater.inflate(R.layout.fragment_main, container, false); 的主要片段。

主要片段:

public class MainFragment extends Fragment {

    private ViewPager viewPager;
    private TabsPagerAdapter mAdapter;
    private CharSequence Titles[]={"Mon","Tue","Wed","Thu","Fri","Sat","Sun"};
    private int Numboftabs =7;
    private SlidingTabLayout tabs;
    private Intent i;

    public MainFragment() {
        // Required empty public constructor
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        View view = inflater.inflate(R.layout.fragment_main, container, false);
        setupUI(view);
        return view;
    }
    void setupUI(View view)
    {
        FrameLayout fab = (FrameLayout)view.findViewById(R.id.main_fab);
        ImageButton imageButton = (ImageButton)view.findViewById(R.id.imgbtn_fab);


        imageButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                String day;
                Boolean editMode = false;

                if(tabs.getCurrentTab() == 0)
                {
                    day = "Mon";
                    i = new Intent(getActivity(),AddEventActivity.class);
                    i.putExtra("day",day);
                    i.putExtra("EditMode",editMode);
                    startActivity(i);

                }
                else if(tabs.getCurrentTab() == 1)
                {
                    day = "Tue";
                    i = new Intent(getActivity(),AddEventActivity.class);
                    i.putExtra("day",day);
                    i.putExtra("EditMode",editMode);
                    startActivity(i);
                }
                else if(tabs.getCurrentTab() == 2)
                {
                    day = "Wed";
                    i = new Intent(getActivity(),AddEventActivity.class);
                    i.putExtra("day",day);
                    i.putExtra("EditMode",editMode);
                    startActivity(i);
                }
                else if(tabs.getCurrentTab() == 3)
                {
                    day = "Thu";
                    i = new Intent(getActivity(),AddEventActivity.class);
                    i.putExtra("day",day);
                    i.putExtra("EditMode",editMode);
                    startActivity(i);
                }

                else if(tabs.getCurrentTab() == 4)
                {
                    day = "Fri";
                    i = new Intent(getActivity(),AddEventActivity.class);
                    i.putExtra("day",day);
                    i.putExtra("EditMode",editMode);
                    startActivity(i);
                }
                else if(tabs.getCurrentTab() == 5)
                {
                    day = "Sat";
                    i = new Intent(getActivity(),AddEventActivity.class);
                    i.putExtra("day",day);
                    i.putExtra("EditMode",editMode);
                    startActivity(i);
                }

                else if(tabs.getCurrentTab() == 6)
                {
                    day = "Sun";
                    i = new Intent(getActivity(),AddEventActivity.class);
                    i.putExtra("day",day);
                    i.putExtra("EditMode",editMode);
                    startActivity(i);
                }
                Log.d("tab",tabs.getCurrentTab() + "");
            }
        });


        mAdapter =  new TabsPagerAdapter(getFragmentManager(),Titles,Numboftabs);
        viewPager = (ViewPager)view.findViewById(R.id.pager);
        viewPager.setAdapter(mAdapter);
        tabs = (SlidingTabLayout)view.findViewById(R.id.tabs);
        tabs.setDistributeEvenly(true);
        tabs.setCustomTabColorizer(new SlidingTabLayout.TabColorizer() {
            @Override
            public int getIndicatorColor(int position) {
                return getResources().getColor(R.color.tab_scroll_color);
            }
        });
        tabs.setViewPager(viewPager);
    }

}

工厂选择器:

   <?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>

片段主要:

    <FrameLayout 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.adgatemedia.offerwallsdk.fragments.MainFragment">

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <utils.SlidingTabLayout
            android:id="@+id/tabs"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:elevation="2dp"
            android:background="?attr/colorPrimary"
            android:layout_alignParentTop="true" />

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

        <LinearLayout
            android:orientation="horizontal"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentBottom="true"
            android:layout_alignParentEnd="true"
            android:layout_alignParentRight="true"
            android:layout_gravity="bottom|end">

            <include layout="@layout/myfab"/>
        </LinearLayout>
    </RelativeLayout>
</FrameLayout>

晶圆厂:

   <?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/main_fab"
    android:layout_width="100dp"
    android:layout_height="100dp"
    android:layout_gravity="bottom|end">

    <View
        android:id="@+id/myfab_shadow"
        android:layout_width="72dp"
        android:layout_height="72dp"
        android:layout_gravity="center"
        android:background="@drawable/fab_shadow"
        android:focusable="false" />

    <ImageButton
        android:id="@+id/imgbtn_fab"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:background="@drawable/fab_selector"
        android:cropToPadding="true"
        android:padding="10dp"
        android:src="@drawable/ic_add_white_36dp"
        android:stateListAnimator="@animator/fab_elevation_selector" />

</FrameLayout>

完整的堆栈跟踪:

 FATAL EXCEPTION: main
02-17 05:42:39.445 3247-3247/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-17 05:42:39.445 3247-3247/com.example.siddhi.timetablelayout E/AndroidRuntime:     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180)
02-17 05:42:39.445 3247-3247/com.example.siddhi.timetablelayout E/AndroidRuntime:     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
02-17 05:42:39.445 3247-3247/com.example.siddhi.timetablelayout E/AndroidRuntime:     at android.app.ActivityThread.access$600(ActivityThread.java:141)
02-17 05:42:39.445 3247-3247/com.example.siddhi.timetablelayout E/AndroidRuntime:     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
02-17 05:42:39.445 3247-3247/com.example.siddhi.timetablelayout E/AndroidRuntime:     at android.os.Handler.dispatchMessage(Handler.java:99)
02-17 05:42:39.445 3247-3247/com.example.siddhi.timetablelayout E/AndroidRuntime:     at android.os.Looper.loop(Looper.java:137)
02-17 05:42:39.445 3247-3247/com.example.siddhi.timetablelayout E/AndroidRuntime:     at android.app.ActivityThread.main(ActivityThread.java:5041)
02-17 05:42:39.445 3247-3247/com.example.siddhi.timetablelayout E/AndroidRuntime:     at java.lang.reflect.Method.invokeNative(Native Method)
02-17 05:42:39.445 3247-3247/com.example.siddhi.timetablelayout E/AndroidRuntime:     at java.lang.reflect.Method.invoke(Method.java:511)
02-17 05:42:39.445 3247-3247/com.example.siddhi.timetablelayout E/AndroidRuntime:     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
02-17 05:42:39.445 3247-3247/com.example.siddhi.timetablelayout E/AndroidRuntime:     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
02-17 05:42:39.445 3247-3247/com.example.siddhi.timetablelayout E/AndroidRuntime:     at dalvik.system.NativeStart.main(Native Method)
02-17 05:42:39.445 3247-3247/com.example.siddhi.timetablelayout E/AndroidRuntime:  Caused by: android.view.InflateException: Binary XML file line #16: Error inflating class ImageButton
02-17 05:42:39.445 3247-3247/com.example.siddhi.timetablelayout E/AndroidRuntime:     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
02-17 05:42:39.445 3247-3247/com.example.siddhi.timetablelayout E/AndroidRuntime:     at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)
02-17 05:42:39.445 3247-3247/com.example.siddhi.timetablelayout E/AndroidRuntime:     at android.view.LayoutInflater.parseInclude(LayoutInflater.java:830)
02-17 05:42:39.445 3247-3247/com.example.siddhi.timetablelayout E/AndroidRuntime:     at android.view.LayoutInflater.rInflate(LayoutInflater.java:736)
02-17 05:42:39.445 3247-3247/com.example.siddhi.timetablelayout E/AndroidRuntime:     at android.view.LayoutInflater.rInflate(LayoutInflater.java:749)
02-17 05:42:39.445 3247-3247/com.example.siddhi.timetablelayout E/AndroidRuntime:     at android.view.LayoutInflater.rInflate(LayoutInflater.java:749)
02-17 05:42:39.445 3247-3247/com.example.siddhi.timetablelayout E/AndroidRuntime:     at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
02-17 05:42:39.445 3247-3247/com.example.siddhi.timetablelayout E/AndroidRuntime:     at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
02-17 05:42:39.445 3247-3247/com.example.siddhi.timetablelayout E/AndroidRuntime:     at com.example.siddhi.timetablelayout.MainFragment.onCreateView(MainFragment.java:33)
02-17 05:42:39.445 3247-3247/com.example.siddhi.timetablelayout E/AndroidRuntime:     at android.support.v4.app.Fragment.performCreateView(Fragment.java:1962)
02-17 05:42:39.445 3247-3247/com.example.siddhi.timetablelayout E/AndroidRuntime:     at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1067)
02-17 05:42:39.445 3247-3247/com.example.siddhi.timetablelayout E/AndroidRuntime:     at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1248)
02-17 05:42:39.445 3247-3247/com.example.siddhi.timetablelayout E/AndroidRuntime:     at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:738)
02-17 05:42:39.445 3247-3247/com.example.siddhi.timetablelayout E/AndroidRuntime:     at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1613)
02-17 05:42:39.445 3247-3247/com.example.siddhi.timetablelayout E/AndroidRuntime:     at android.support.v4.app.FragmentController.execPendingActions(FragmentController.java:330)
02-17 05:42:39.445 3247-3247/com.example.siddhi.timetablelayout E/AndroidRuntime:     at android.support.v4.app.FragmentActivity.onStart(FragmentActivity.java:547)
02-17 05:42:39.445 3247-3247/com.example.siddhi.timetablelayout E/AndroidRuntime:     at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1164)
02-17 05:42:39.445 3247-3247/com.example.siddhi.timetablelayout E/AndroidRuntime:     at android.app.Activity.performStart(Activity.java:5114)
02-17 05:42:39.445 3247-3247/com.example.siddhi.timetablelayout E/AndroidRuntime:     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2153)
02-17 05:42:39.445 3247-3247/com.example.siddhi.timetablelayout E/AndroidRuntime:     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230) 
02-17 05:42:39.445 3247-3247/com.example.siddhi.timetablelayout E/AndroidRuntime:     at android.app.ActivityThread.access$600(ActivityThread.java:141) 
02-17 05:42:39.445 3247-3247/com.example.siddhi.timetablelayout E/AndroidRuntime:     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234) 
02-17 05:42:39.445 3247-3247/com.example.siddhi.timetablelayout E/AndroidRuntime:     at android.os.Handler.dispatchMessage(Handler.java:99) 
02-17 05:42:39.445 3247-3247/com.example.siddhi.timetablelayout E/AndroidRuntime:     at android.os.Looper.loop(Looper.java:137) 
02-17 05:42:39.445 3247-3247/com.example.siddhi.timetablelayout E/AndroidRuntime:     at android.app.ActivityThread.main(ActivityThread.java:5041) 
02-17 05:42:39.445 3247-3247/com.example.siddhi.timetablelayout E/AndroidRuntime:     at java.lang.reflect.Method.invokeNative(Native Method) 
02-17 05:42:39.445 3247-3247/com.example.siddhi.timetablelayout E/AndroidRuntime:     at java.lang.reflect.Method.invoke(Method.java:511) 
02-17 05:42:39.445 3247-3247/com.example.siddhi.timetablelayout E/AndroidRuntime:     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793) 
02-17 05:42:39.445 3247-3247/com.example.siddhi.timetablelayout E/AndroidRuntime:     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560) 
02-17 05:42:39.445 3247-3247/com.example.siddhi.timetablelayout E/AndroidRuntime:     at dalvik.system.NativeStart.main(Native Method) 
02-17 05:42:39.445 3247-3247/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-17 05:42:39.445 3247-3247/com.example.siddhi.timetablelayout E/AndroidRuntime:     at android.content.res.Resources.loadDrawable(Resources.java:1953)
02-17 05:42:39.445 3247-3247/com.example.siddhi.timetablelayout E/AndroidRuntime:     at android.content.res.TypedArray.getDrawable(TypedArray.java:601)
02-17 05:42:39.445 3247-3247/com.example.siddhi.timetablelayout E/AndroidRuntime:     at android.view.View.<init>(View.java:3330)
02-17 05:42:39.445 3247-3247/com.example.siddhi.timetablelayout E/AndroidRuntime:     at android.widget.ImageView.<init>(ImageView.java:114)
02-17 05:42:39.445 3247-3247/com.example.siddhi.timetablelayout E/AndroidRuntime:     at android.widget.ImageButton.<init>(ImageButton.java:87)
02-17 05:42:39.445 3247-3247/com.example.siddhi.timetablelayout E/AndroidRuntime:     at android.support.v7.widget.AppCompatImageButton.<init>(AppCompatImageButton.java:59)
02-17 05:42:39.445 3247-3247/com.example.siddhi.timetablelayout E/AndroidRuntime:     at android.support.v7.widget.AppCompatImageButton.<init>(AppCompatImageButton.java:55)
02-17 05:42:39.445 3247-3247/com.example.siddhi.timetablelayout E/AndroidRuntime:     at android.support.v7.app.AppCompatViewInflater.createView(AppCompatViewInflater.java:107)
02-17 05:42:39.445 3247-3247/com.example.siddhi.timetablelayout E/AndroidRuntime:     at android.support.v7.app.AppCompatDelegateImplV7.createView(AppCompatDelegateImplV7.java:938)
02-17 05:42:39.445 3247-3247/com.example.siddhi.timetablelayout E/AndroidRuntime:     at android.support.v7.app.AppCompatDelegateImplV7.onCreateView(AppCompatDelegateImplV7.java:992)
02-17 05:42:39.445 3247-3247/com.example.siddhi.timetablelayout E/AndroidRuntime:     at android.support.v4.view.LayoutInflaterCompatHC$FactoryWrapperHC.onCreateView(LayoutInflaterCompatHC.java:44)
02-17 05:42:39.445 3247-3247/com.example.siddhi.timetablelayout E/AndroidRuntime:     at android.view.LayoutInflater$FactoryMerger.onCreateView(LayoutInflater.java:171)
02-17 05:42:39.445 3247-3247/com.example.siddhi.timetablelayout E/AndroidRuntime:     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:675)
02-17 05:42:39.445 3247-3247/com.example.siddhi.timetablelayout E/AndroidRuntime:     at android.view.LayoutInflater.rInflate(LayoutInflater.java:746) 
02-17 05:42:39.445 3247-3247/com.example.siddhi.timetablelayout E/AndroidRuntime:     at android.view.LayoutInflater.parseInclude(LayoutInflater.java:830) 
02-17 05:42:39.445 3247-3247/com.example.siddhi.timetablelayout E/AndroidRuntime:     at android.view.LayoutInflater.rInflate(LayoutInflater.java:736) 
02-17 05:42:39.445 3247-3247/com.example.siddhi.timetablelayout E/AndroidRuntime:     at android.view.LayoutInflater.rInflate(LayoutInflater.java:749) 
02-17 05:42:39.445 3247-3247/com.example.siddhi.timetablelayout E/AndroidRuntime:     at android.view.LayoutInflater.rInflate(LayoutInflater.java:749) 
02-17 05:42:39.445 3247-3247/com.example.siddhi.timetablelayout E/AndroidRuntime:     at android.view.LayoutInflater.inflate(LayoutInflater.java:489) 
02-17 05:42:39.445 3247-3247/com.example.siddhi.timetablelayout E/AndroidRuntime:     at android.view.LayoutInflater.inflate(LayoutInflater.java:396) 
02-17 05:42:39.445 3247-3247/com.example.siddhi.timetablelayout E/AndroidRuntime:     at com.example.siddhi.timetablelayout.MainFragment.onCreateView(MainFragment.java:33) 
02-17 05:42:39.445 3247-3247/com.example.siddhi.timetablelayout E/AndroidRuntime:     at android.support.v4.app.Fragment.performCreateView(Fragment.java:1962) 
02-17 05:42:39.445 3247-3247/com.example.siddhi.timetablelayout E/AndroidRuntime:     at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1067) 
02-17 05:42:39.445 3247-3247/com.example.siddhi.timetablelayout E/AndroidRuntime:     at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1248) 
02-17 05:42:39.445 3247-3247/com.example.siddhi.timetablelayout E/AndroidRuntime:     at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:738) 
02-17 05:42:39.445 3247-3247/com.example.siddhi.timetablelayout E/AndroidRuntime:     at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1613) 
02-17 05:42:39.445 3247-3247/com.example.siddhi.timetablelayout E/AndroidRuntime:     at android.support.v4.app.FragmentController.execPendingActions(FragmentController.java:330) 
02-17 05:42:39.445 3247-3247/com.example.siddhi.timetablelayout E/AndroidRuntime:     at android.support.v4.app.FragmentActivity.onStart(FragmentActivity.java:547) 
02-17 05:42:39.445 3247-3247/com.example.siddhi.timetablelayout E/AndroidRuntime:     at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1164) 
02-17 05:42:39.445 3247-3247/com.example.siddhi.timetablelayout E/AndroidRuntime:     at android.app.Activity.performStart(Activity.java:5114) 
02-17 05:42:39.445 3247-3247/com.example.siddhi.timetablelayout E/AndroidRuntime:     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2153) 
02-17 05:42:39.445 3247-3247/com.example.siddhi.timetablelayout E/AndroidRuntime:     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230) 
02-17 05:42:39.445 3247-3247/com.example.siddhi.timetablelayout E/AndroidRuntime:     at android.app.ActivityThread.access$600(ActivityThread.java:141) 
02-17 05:42:39.445 3247-3247/com.example.siddhi.timetablelayout E/AndroidRuntime:     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234) 
02-17 05:42:39.445 3247-3247/com.example.siddhi.timetablelayout E/AndroidRuntime:     at android.os.Handler.dispatchMessage(Handler.java:99) 
02-17 05:42:39.445 3247-3247/com.example.siddhi.timetablelayout E/AndroidRuntime:     at android.os.Looper.loop(Looper.java:137) 
02-17 05:42:39.445 3247-3247/com.example.siddhi.timetablelayout E/AndroidRuntime:     at android.app.ActivityThread.main(ActivityThread.java:5041) 
02-17 05:42:39.445 3247-3247/com.example.siddhi.timetablelayout E/AndroidRuntime:     at java.lang.reflect.Method.invokeNative(Native Method) 
02-17 05:42:39.445 3247-3247/com.example.siddhi.timetablelayout E/AndroidRuntime:     at java.lang.reflect.Method.invoke(Method.java:511) 
02-17 05:42:39.445 3247-3247/com.example.siddhi.timetablelayout E/AndroidRuntime:     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793) 
02-17 05:42:39.445 3247-3247/com.example.siddhi.timetablelayout E/AndroidRuntime:     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560) 
02-17 05:42:39.445 3247-3247/com.example.siddhi.timetablelayout E/AndroidRuntime:     at dalvik.system.NativeStart.main(Native Method) 
02-17 05:42:39.445 3247-3247/com.example.siddhi.timetablelayout E/AndroidRuntime:  Caused by: java.lang.UnsupportedOperationException: Can't convert to color: type=0x2
02-17 05:42:39.445 3247-3247/com.example.siddhi.timetablelayout E/AndroidRuntime:     at android.content.res.TypedArray.getColor(TypedArray.java:326)
02-17 05:42:39.445 3247-3247/com.example.siddhi.timetablelayout E/AndroidRuntime:     at android.graphics.drawable.GradientDrawable.inflate(GradientDrawable.java:967)
02-17 05:42:39.445 3247-3247/com.example.siddhi.timetablelayout E/AndroidRuntime:     at android.graphics.drawable.Drawable.createFromXmlInner(Drawable.java:885)

你能告诉我这里有什么问题吗?

4

6 回答 6

7

这个例外

02-17 05:42:39.445 3247-3247/com.example.siddhi.timetablelayout E/AndroidRuntime: 由: java.lang.UnsupportedOperationException: 无法转换为颜色: type=0x2 02-17 05:42:39.445 3247-3247/com.example.siddhi.timetablelayout E/AndroidRuntime:在 android.content.res.TypedArray.getColor(TypedArray.java:326) 02-17 05:42:39.445 3247-3247/com.example.siddhi。 timetablelayout E/AndroidRuntime:位于 android.graphics.drawable.GradientDrawable.inflate(GradientDrawable.java:967) 02-17 05:42:39.445 3247-3247/com.example.siddhi.timetablelayout E/AndroidRuntime:位于 android.graphics。 drawable.Drawable.createFromXmlInner(Drawable.java:885)

得出的结论是这条线<solid android:color="?attr/colorAccent" />fab_selector罪魁祸首。尝试更改colorHEX value然后测试。

希望这可以帮助。

于 2016-02-17T06:17:38.853 回答
4

是的。您需要创建一个像“drawable-v21”这样的文件夹。

于 2018-07-30T04:16:44.073 回答
4

我也遇到了这个问题,但我解决了。

在我的情况下,错误是我为 ImageButton 导入的 png 图像由 android studio 自动保存在 drawable-v24 中。我从那里复制了 png 并将其粘贴到 drawable 文件夹中。

于 2020-10-17T09:12:49.860 回答
0

这是谷歌上的最高结果我想分享为我解决相同错误的原因(尽管与上面的问题不同)

  • 确保构建工具版本是最新的
  • 我有一个矢量 src drawable 和一个高程值(仅限 API 21+)的组合,这似乎使它绊倒了。我为 v21 制作了一个单独的布局以获得高程值(但在任何地方都可以绘制矢量),这为我解决了
于 2017-11-20T23:24:05.090 回答
0

image.png 的格式不正确。我的解决方案:我在我的 PC 上安装了 greenshot 以从我的屏幕 https://getgreenshot.org/中获取图像 然后我将图像保存为我的 res/drawable 中的 png 文件。这对我有用

于 2019-05-15T06:39:24.673 回答
0

解决了我的问题(rounded_corner_image_view.xml (v24)):

android:background="@drawable/rounded_corner_image_view"

我的背景可绘制是v24。创建了一个较低的可绘制对象和中提琴

于 2022-01-19T08:24:25.590 回答