Android 7.0 showing TextView Inflating error

点点圈 提交于 2020-07-10 05:56:07

问题


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>

My app is running perfectly but when I'm running my app in android 7.0 it's showing me this error. Error what I'm getting:

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

I think this error is also can formed by firebase because

which textview have +id/tvCollege is not showing any error because I'm not putting any data in it through firebase

Theme for whole application

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

回答1:


It's too simple. I have removed

<item name="android:fontFamily">sans-serif-medium</item>

from styles.xml

Thanks! It's working perfect now



来源:https://stackoverflow.com/questions/61167493/android-7-0-showing-textview-inflating-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!