Двоичная XML строка файла № 28: Ошибка надувания класса android .widget.TextView - PullRequest
1 голос
/ 14 апреля 2020

Это мой макет: -

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#fdfdfe"
tools:context=".activity.LoginActivity">

<androidx.core.widget.NestedScrollView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_above="@+id/bottom_lay_login"
    android:fillViewport="true">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical"
        android:padding="42sp">

        <ImageView
            android:layout_width="80dp"
            android:layout_height="80dp"
            android:layout_gravity="center"
            android:layout_marginTop="42sp"
            android:src="@drawable/foodx_restaurant_logo" />

        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="42sp"
            android:text="@string/enter_the_details_to_login"
            android:textColor="@color/colorPrimaryText"
            android:textSize="13sp" />

        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="42sp"
            android:text="@string/email"
            android:textColor="@color/colorPrimaryText"
            android:textSize="10sp" />

        <EditText
            android:id="@+id/et_email"
            android:layout_width="match_parent"
            android:layout_height="32sp"
            android:layout_marginTop="4sp"
            android:background="@drawable/edit_text_rounded_corner_bg"
            android:imeOptions="actionNext"
            android:inputType="textEmailAddress"
            android:padding="4sp"
            android:textColor="@color/colorSecondaryText"
            android:textSize="13sp" />

        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="42sp"
            android:text="@string/password"
            android:textColor="@color/colorPrimaryText"
            android:textSize="10sp" />

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="4sp"
            android:background="@drawable/edit_text_rounded_corner_bg"
            android:orientation="horizontal">

            <EditText
                android:id="@+id/et_password"
                android:layout_width="match_parent"
                android:layout_height="32sp"
                android:layout_weight="1"
                android:background="@null"
                android:hint="@string/password"
                android:imeOptions="actionDone"
                android:inputType="textWebPassword"
                android:padding="4sp"
                android:textColor="@color/colorSecondaryText"
                android:textSize="13sp" />

            <ImageView
                android:id="@+id/et_password_eye_img"
                android:layout_width="30sp"
                android:layout_height="match_parent"
                android:layout_marginRight="4sp"
                android:contentDescription="@string/app_name"
                android:padding="4sp"
                android:src="@drawable/ic_eye_open"
                android:tint="@color/grey" />
        </LinearLayout>

        <TextView
            android:id="@+id/txt_forgot_password"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:padding="42sp"
            android:text="@string/forgot_password"
            android:textColor="@color/colorTheme"
            android:textSize="13sp" />

    </LinearLayout>

</androidx.core.widget.NestedScrollView>

<LinearLayout
    android:id="@+id/bottom_lay_login"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:layout_marginStart="42sp"
    android:layout_marginEnd="42sp"
    android:orientation="vertical">

    <Button
        android:id="@+id/login_btn"
        android:layout_width="match_parent"
        android:layout_height="42sp"
        android:layout_marginTop="42sp"
        android:background="@drawable/rounded_button"
        android:text="@string/login"
        android:textColor="@color/colorWhite" />

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:gravity="center"
        android:orientation="horizontal">

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/donot_have_an_account"
            android:textColor="@color/colorPrimaryText"
            android:textSize="10sp" />

        <TextView
            android:id="@+id/txt_register"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:paddingLeft="42sp"
            android:paddingTop="42sp"
            android:paddingBottom="42sp"
            android:text="@string/register"
            android:textAllCaps="false"
            android:textColor="@color/colorTheme"
            android:textSize="10sp" />

    </LinearLayout>

</LinearLayout>

</RelativeLayout>

Это мои журналы: -

Caused by: android.view.InflateException: Binary XML file line #28 in com.dw.foodxrestaurant:layout/activity_login: Binary XML file line #28 in com.dw.foodxrestaurant:layout/activity_login: Error inflating class TextView
     Caused by: android.view.InflateException: Binary XML file line #28 in com.dw.foodxrestaurant:layout/activity_login: Error inflating class TextView
     Caused by: java.lang.IndexOutOfBoundsException: index=0 out of bounds (limit=0, nb=4)
        at java.nio.Buffer.checkIndex(Buffer.java:564)
        at java.nio.DirectByteBuffer.getInt(DirectByteBuffer.java:570)
        at android.graphics.fonts.FontFileUtil.analyzeStyle(FontFileUtil.java:94)
        at android.graphics.fonts.Font$Builder.build(Font.java:364)
        at android.graphics.Typeface$Builder.build(Typeface.java:596)
        at android.content.res.ResourcesImpl.loadFont(ResourcesImpl.java:1032)
        at android.content.res.Resources.getFont(Resources.java:408)
        at android.content.res.TypedArray.getFont(TypedArray.java:1035)
        at android.widget.TextView.readTextAppearance(TextView.java:4029)
        at android.widget.TextView.<init>(TextView.java:1079)
        at android.widget.TextView.<init>(TextView.java:978)
        at androidx.appcompat.widget.AppCompatTextView.<init>(AppCompatTextView.java:99)
        at androidx.appcompat.widget.AppCompatTextView.<init>(AppCompatTextView.java:95)
        at androidx.appcompat.app.AppCompatViewInflater.createTextView(AppCompatViewInflater.java:182)
        at androidx.appcompat.app.AppCompatViewInflater.createView(AppCompatViewInflater.java:103)
        at androidx.appcompat.app.AppCompatDelegateImpl.createView(AppCompatDelegateImpl.java:1407)
        at androidx.appcompat.app.AppCompatDelegateImpl.onCreateView(AppCompatDelegateImpl.java:1457)
        at android.view.LayoutInflater.tryCreateView(LayoutInflater.java:1063)
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:999)
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:963)
        at android.view.LayoutInflater.rInflate(LayoutInflater.java:1125)
        at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:1086)
        at android.view.LayoutInflater.rInflate(LayoutInflater.java:1128)
        at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:1086)
        at android.view.LayoutInflater.rInflate(LayoutInflater.java:1128)
        at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:1086)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:682)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:534)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:481)
        at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:555)
        at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:161)
        at com.dw.foodxrestaurant.activity.LoginActivity.onCreate(LoginActivity.java:76)

Я не могу получить проблемы, но я проверил все мои библиотеки до date, Очистить проект, а также сделать недействительным и перезапустить мою студию.

Примечание: - Устройства до android 9 работают с тем же кодом, но android 10 выдает ошибку

Ответы [ 3 ]

1 голос
/ 14 апреля 2020

Я думаю, что ваша проблема с ImageView отображением изображения больше, чем на экране, попробуйте заменить каким-нибудь цветным кодом и отметьте

android:src="@drawable/foodx_restaurant_logo"

заменить это изображение

0 голосов
/ 14 апреля 2020

Согласно вашему xml ошибка указывает на Textview и связана с некоторыми деталями в textview. Я думаю, что проблема в том, что colorPrimaryText установлен неправильно. Пожалуйста, убедитесь, что это свойство установлено правильно. Я попытался запустить ваш код в android 10, и он работает нормально. Пожалуйста, проверьте и попробуйте это решение. Надеюсь, что это решит вашу проблему.

0 голосов
/ 14 апреля 2020

Существует проблема с andrpid Q, иногда с загрузкой текстового шрифта. В вашей стековой трассировке я тоже вижу проблему: если вы используете какой-либо файл нестандартного шрифта, проверьте его, если вы не используете какой-либо шрифт, затем импортируйте файл шрифта, который вы поддерживаете в вашем проекте, так что если он не получает его из ОС, он может получить его из ресурса. Проверьте ниже ссылку

Cra sh при использовании связанного шрифта ttf на Android 10 / Android Q

...