fragment里面用了constraintlayout
结果一个劲报错~~
我的天啊~~
11-29 17:30:12.053 19479-19479/com.youhui2000.dabaifanyi E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.youhui2000.dabaifanyi, PID: 19479
android.view.InflateException: Binary XML file line #0: Error inflating class <unknown>
at android.view.LayoutInflater.createView(LayoutInflater.java:620)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:696)
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 com.youhui2000.dabaifanyi.ui.base.BaseFragment.onCreateView(BaseFragment.java:31)
最后发现 原来是不该设置这个背景~
错误xml
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/linearLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/ic_launcher_background">
<TextView
android:id="@+id/textView"
android:layout_width="261dp"
android:layout_height="272dp"
android:layout_marginBottom="8dp"
android:layout_marginTop="8dp"
android:text="main_fragment"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</android.support.constraint.ConstraintLayout>
将background取消 果断正常了·~
新手伤不起
总结:资源文件引用错误因为后面还是遇到了同样的问题~~ 结果是某个drawable放到drawable-v24里面去了,放回drawable就好了