本文介绍了Android 7.0 显示 TextView Inflating 错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的 XML 代码:-
My XML CODE:-
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/white"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="10dp">
<TextView
android:id="@+id/tvCollege"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:text="NGF\nCOLLEGE"
android:textColor="@android:color/black" />
<TextView
android:id="@+id/tvNameTeacher"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_gravity="center"
android:layout_toLeftOf="@id/imgBarTeachers"
android:layout_toRightOf="@id/tvCollege"
android:gravity="center"
android:textAllCaps="true"
android:textColor="@color/colorAccent"
android:textSize="18sp" />
<ImageView
android:id="@+id/imgBarTeachers"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:src="@drawable/ic_menu" />
</RelativeLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@android:color/black" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="10dp"
android:paddingTop="20dp"
android:paddingRight="10dp"
android:paddingBottom="20dp">
<ImageView
android:layout_width="96dp"
android:layout_height="96dp"
android:padding="10dp"
android:src="@drawable/ic_teachers" />
<View
android:layout_width="1dp"
android:layout_height="76dp"
android:layout_gravity="center_vertical"
android:layout_marginLeft="9dp"
android:layout_marginRight="9dp"
android:background="@android:color/black" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:orientation="vertical">
<TextView
android:id="@+id/tvSubjectTeacher"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAllCaps="true"
android:textColor="#414141"
android:textSize="18sp" />
<TextView
android:id="@+id/tvMobileTeacher"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="18sp" />
<TextView
android:id="@+id/tvMailTeacher"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="18sp" />
</LinearLayout>
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@android:color/black" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recyclerViewMenuTeacher"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="none" />
</LinearLayout>
我的应用运行完美,但是当我在 android 7.0 中运行我的应用时,它向我显示了这个错误.我得到的错误:
Process: com.ngfcet.ngfconnection, PID: 21684
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.ngfcet.ngfconnection/com.ngfcet.ngfconnection.activities.TeacherActivity}: android.view.InflateException: Binary XML file line #21: Binary XML file line #21: Error inflating class TextView
我认为这个错误也可以由firebase形成,因为
I think this error is also can formed by firebase because
哪个 textview 有 +id/tvCollege 没有显示任何错误,因为我没有通过 firebase 将任何数据放入其中
which textview have +id/tvCollege is not showing any error because I'm not putting any data in it through firebase
整个应用程序的主题
<resources xmlns:tools="http://schemas.android.com/tools">
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
<item name="android:windowLightStatusBar" tools:targetApi="m">true</item>
<item name="android:statusBarColor" tools:targetApi="lollipop">@android:color/white</item>
<item name="android:windowLightNavigationBar" tools:targetApi="o_mr1">true</item>
<item name="android:navigationBarColor" tools:targetApi="lollipop">@android:color/white</item>d
<item name="android:fontFamily">sans-serif-medium</item>
</style>
</resources>
推荐答案
太简单了.我已经删除
<item name="android:fontFamily">sans-serif-medium</item>
来自styles.xml
谢谢!现在完美运行
这篇关于Android 7.0 显示 TextView Inflating 错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!