找不到类'android.graphics.drawable.RippleDrawable;

时间:2017-12-06 03:28:22

标签: java android

我试图在手机上运行它(SdkVersion 18)但它在SdkVersion中运行良好  20或迟到。不知道这里的错误在哪里......

Could not find class 'android.graphics.drawable.RippleDrawable', referenced from method android.support.v7.widget.AppCompatImageHelper.hasOverlappingRendering
 FATAL EXCEPTION: main
                                                                   android.view.InflateException: Binary XML file line #2: Error inflating class <unknown>
                                                                       at android.view.LayoutInflater.createView(LayoutInflater.java:620)
                                                                       at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
                                                                       at android.view.LayoutInflater.onCreateView(LayoutInflater.java:669)
                                                                       at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:694)
                                                                       at android.view.LayoutInflater.inflate(LayoutInflater.java:469)
                                                                       at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
                                                                       at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
                                                                       at chaos.tech.suppertest.base.StorageExpandAdapter.getGroupView(StorageExpandAdapter.java:80)
                                                                       at android.widget.ExpandableListConnector.getView(ExpandableListConnector.java:446)
                                                                       at android.widget.HeaderViewListAdapter.getView(HeaderViewListAdapter.java:220)
                                                                       at android.widget.AbsListView.obtainView(AbsListView.java:2181)
                                                                       at android.widget.ListView.makeAndAddView(ListView.java:1880)
                                                                       at android.widget.ListView.fillDown(ListView.java:687)
                                                                       at android.widget.ListView.fillDown(ListView.java:666)
                                                                       at android.widget.ListView.fillFromTop(ListView.java:758)
                                                                       at android.widget.ListView.layoutChildren(ListView.java:1695)
                                                                       at android.widget.AbsListView.onLayout(AbsListView.java:2016)
                                                                       at android.view.View.layout(View.java:14471)
                                                                       at android.view.ViewGroup.layout(ViewGroup.java:4562)
                                                                       at android.widget.FrameLayout.onLayout(FrameLayout.java:452)
                                                                       at android.view.View.layout(View.java:14471)
                                                                       at android.view.ViewGroup.layout(ViewGroup.java:4562)
                                                                       at android.widget.FrameLayout.onLayout(FrameLayout.java:452)
                                                                       at android.view.View.layout(View.java:14471)
                                                                       at android.view.ViewGroup.layout(ViewGroup.java:4562)
                                                                       at android.support.design.widget.HeaderScrollingViewBehavior.layoutChild(HeaderScrollingViewBehavior.java:131)
                                                                       at android.support.design.widget.ViewOffsetBehavior.onLayoutChild(ViewOffsetBehavior.java:42)
                                                                       at android.support.design.widget.AppBarLayout$ScrollingViewBehavior.onLayoutChild(AppBarLayout.java:1389)
                                                                       at android.support.design.widget.CoordinatorLayout.onLayout(CoordinatorLayout.java:868)
                                                                       at android.view.View.layout(View.java:14471)
                                                                       at android.view.ViewGroup.layout(ViewGroup.java:4562)
                                                                       at android.widget.FrameLayout.onLayout(FrameLayout.java:452)
                                                                       at android.view.View.layout(View.java:14471)
                                                                       at android.view.ViewGroup.layout(ViewGroup.java:4562)
                                                                       at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1671)
                                                                       at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1525)
                                                                       at android.widget.LinearLayout.onLayout(LinearLayout.java:1434)
                                                                       at android.view.View.layout(View.java:14471)
                                                                       at android.view.ViewGroup.layout(ViewGroup.java:4562)
                                                                       at android.widget.FrameLayout.onLayout(FrameLayout.java:452)
                                                                       at android.view.View.layout(View.java:14471)
                                                                       at android.view.ViewGroup.layout(ViewGroup.java:4562)
                                                                       at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1671)
                                                                       at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1525)
                                                                       at android.widget.LinearLayout.onLayout(LinearLayout.java:1434)
                                                                       at android.view.View.layout(View.java:14471)
                                                                       at android.view.ViewGroup.layout(ViewGroup.java:4562)
                                                                       at android.widget.FrameLayout.onLayout(FrameLayout.java:452)
                                                                       at android.view.View.layout(View.java:14471)
                                                                       at android.view.ViewGroup.layout(ViewGroup.java:4562)
                                                                       at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:1984)
                                                                       at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1738)
                                                                       at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1008)
                                                                       at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5508)
                                                                       at android.view.Choreographer$CallbackRecord.run(Choreographer.java:749)
                                                                       at android.view.Choreographer.doCallbacks(Choreographer.java:562)
                                                                       at android.view.Choreographer.doFrame(Choreographer.java:532)
                                                                       at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:735)
                                                                       at android.os.Handler.handleCallback(Handler.java:730)
                                                                       at android.os.Handler.dispatchMessage(Handler.java:92)
                                                                    at android.os.Looper.loop(Looper.java:

1 个答案:

答案 0 :(得分:0)

  

涟漪效应仅适用于sdk 21+,因此您可以设置一个条件来检查移动sdk是否为21+,因此您可以添加效果。

private void setRippleEffect(){

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
        {
            your_button_id.setBackgroundDrawable(getResources().getDrawable(R.drawable.you_ripple_effect));
        }
    }