是我的xml文件:
<?xml version="1.0" encoding="utf-8"?>
<!-- item_feed.xml -->
<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:id="@+id/card_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_margin="8dp"
>
</android.support.v7.widget.CardView>
logcat的:
02-02 15:28:19.537: E/AndroidRuntime(1738): FATAL EXCEPTION: main
02-02 15:28:19.537: E/AndroidRuntime(1738): android.view.InflateException: Binary XML file line #3: Error inflating class android.support.v7.widget.CardView
02-02 15:28:19.537: E/AndroidRuntime(1738): at android.view.LayoutInflater.createView(LayoutInflater.java:613)
02-02 15:28:19.537: E/AndroidRuntime(1738): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:687)
02-02 15:28:19.537: E/AndroidRuntime(1738): at android.view.LayoutInflater.inflate(LayoutInflater.java:466)
02-02 15:28:19.537: E/AndroidRuntime(1738): at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
02-02 15:28:19.537: E/AndroidRuntime(1738): at io.github.froger.instamaterial.FeedAdapter.onCreateViewHolder(FeedAdapter.java:52)
02-02 15:28:19.537: E/AndroidRuntime(1738): at android.support.v7.widget.RecyclerView$Adapter.createViewHolder(RecyclerView.java:4121)
02-02 15:28:19.537: E/AndroidRuntime(1738): at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:3431)
02-02 15:28:19.537: E/AndroidRuntime(1738): at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:3340)
02-02 15:28:19.537: E/AndroidRuntime(1738): at android.support.v7.widget.LinearLayoutManager$LayoutState.next(LinearLayoutManager.java:1810)
02-02 15:28:19.537: E/AndroidRuntime(1738): at android.support.v7.widget.LinearLayoutManager.layoutChunk(LinearLayoutManager.java:1306)
02-02 15:28:19.537: E/AndroidRuntime(1738): at android.support.v7.widget.LinearLayoutManager.fill(LinearLayoutManager.java:1269)
02-02 15:28:19.537: E/AndroidRuntime(1738): at android.support.v7.widget.LinearLayoutManager.onLayoutChildren(LinearLayoutManager.java:523)
02-02 15:28:19.537: E/AndroidRuntime(1738): at android.support.v7.widget.RecyclerView.dispatchLayout(RecyclerView.java:1988)
02-02 15:28:19.537: E/AndroidRuntime(1738): at android.support.v7.widget.RecyclerView.onLayout(RecyclerView.java:2237)
02-02 15:28:19.537: E/AndroidRuntime(1738): at android.view.View.layout(View.java:13754)
02-02 15:28:19.537: E/AndroidRuntime(1738): at android.view.ViewGroup.layout(ViewGroup.java:4362)
02-02 15:28:19.537: E/AndroidRuntime(1738): at android.widget.RelativeLayout.onLayout(RelativeLayout.java:948)
02-02 15:28:19.537: E/AndroidRuntime(1738): at android.view.View.layout(View.java:13754)
02-02 15:28:19.537: E/AndroidRuntime(1738): at android.view.ViewGroup.layout(ViewGroup.java:4362)
02-02 15:28:19.537: E/AndroidRuntime(1738): at android.widget.FrameLayout.onLayout(FrameLayout.java:448)
02-02 15:28:19.537: E/AndroidRuntime(1738): at android.view.View.layout(View.java:13754)
02-02 15:28:19.537: E/AndroidRuntime(1738): at android.view.ViewGroup.layout(ViewGroup.java:4362)
02-02 15:28:19.537: E/AndroidRuntime(1738): at android.support.v4.widget.DrawerLayout.onLayout(DrawerLayout.java:890)
02-02 15:28:19.537: E/AndroidRuntime(1738): at android.view.View.layout(View.java:13754)
02-02 15:28:19.537: E/AndroidRuntime(1738): at android.view.ViewGroup.layout(ViewGroup.java:4362)
02-02 15:28:19.537: E/AndroidRuntime(1738): at android.widget.FrameLayout.onLayout(FrameLayout.java:448)
02-02 15:28:19.537: E/AndroidRuntime(1738): at android.view.View.layout(View.java:13754)
02-02 15:28:19.537: E/AndroidRuntime(1738): at android.view.ViewGroup.layout(ViewGroup.java:4362)
02-02 15:28:19.537: E/AndroidRuntime(1738): at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1649)
02-02 15:28:19.537: E/AndroidRuntime(1738): at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1507)
02-02 15:28:19.537: E/AndroidRuntime(1738): at android.widget.LinearLayout.onLayout(LinearLayout.java:1420)
02-02 15:28:19.537: E/AndroidRuntime(1738): at android.view.View.layout(View.java:13754)
02-02 15:28:19.537: E/AndroidRuntime(1738): at android.view.ViewGroup.layout(ViewGroup.java:4362)
02-02 15:28:19.537: E/AndroidRuntime(1738): at android.widget.FrameLayout.onLayout(FrameLayout.java:448)
02-02 15:28:19.537: E/AndroidRuntime(1738): at android.view.View.layout(View.java:13754)
02-02 15:28:19.537: E/AndroidRuntime(1738): at android.view.ViewGroup.layout(ViewGroup.java:4362)
02-02 15:28:19.537: E/AndroidRuntime(1738): at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1649)
02-02 15:28:19.537: E/AndroidRuntime(1738): at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1507)
02-02 15:28:19.537: E/AndroidRuntime(1738): at android.widget.LinearLayout.onLayout(LinearLayout.java:1420)
02-02 15:28:19.537: E/AndroidRuntime(1738): at android.view.View.layout(View.java:13754)
02-02 15:28:19.537: E/AndroidRuntime(1738): at android.view.ViewGroup.layout(ViewGroup.java:4362)
02-02 15:28:19.537: E/AndroidRuntime(1738): at android.widget.FrameLayout.onLayout(FrameLayout.java:448)
02-02 15:28:19.537: E/AndroidRuntime(1738): at android.view.View.layout(View.java:13754)
02-02 15:28:19.537: E/AndroidRuntime(1738): at android.view.ViewGroup.layout(ViewGroup.java:4362)
02-02 15:28:19.537: E/AndroidRuntime(1738): at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:1866)
02-02 15:28:19.537: E/AndroidRuntime(1738): at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1687)
02-02 15:28:19.537: E/AndroidRuntime(1738): at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:998)
02-02 15:28:19.537: E/AndroidRuntime(1738): at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:4212)
02-02 15:28:19.537: E/AndroidRuntime(1738): at android.view.Choreographer$CallbackRecord.run(Choreographer.java:725)
02-02 15:28:19.537: E/AndroidRuntime(1738): at android.view.Choreographer.doCallbacks(Choreographer.java:555)
02-02 15:28:19.537: E/AndroidRuntime(1738): at android.view.Choreographer.doFrame(Choreographer.java:525)
02-02 15:28:19.537: E/AndroidRuntime(1738): at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:711)
02-02 15:28:19.537: E/AndroidRuntime(1738): at android.os.Handler.handleCallback(Handler.java:615)
02-02 15:28:19.537: E/AndroidRuntime(1738): at android.os.Handler.dispatchMessage(Handler.java:92)
02-02 15:28:19.537: E/AndroidRuntime(1738): at android.os.Looper.loop(Looper.java:137)
02-02 15:28:19.537: E/AndroidRuntime(1738): at android.app.ActivityThread.main(ActivityThread.java:4745)
02-02 15:28:19.537: E/AndroidRuntime(1738): at java.lang.reflect.Method.invokeNative(Native Method)
02-02 15:28:19.537: E/AndroidRuntime(1738): at java.lang.reflect.Method.invoke(Method.java:511)
02-02 15:28:19.537: E/AndroidRuntime(1738): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
02-02 15:28:19.537: E/AndroidRuntime(1738): at com.android.internal.os.ZygoteInit.main(ZygoteInit.j
我还使用jar和作为库项目在项目中添加了CardView库,但仍然面临这个问题。
我已尝试过以下链接:
Error inflating class and android.support.v7.widget.CardView