Voici ma mise en page: -
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)
Voici mes journaux: -
<?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>
Je ne parviens pas à obtenir les problèmes mais je J'ai vérifié que toutes mes bibliothèques sont à jour, nettoyer le projet et également invalider et redémarrer mon studio.
Remarque: - Les appareils jusqu'à Android 9 fonctionnent bien avec le même code mais Android 10 me donne une erreur p>
3 Réponses :
Je pense que votre problème avec l'image d'affichage ImageView
est plus grande que l'écran, essayez de la remplacer par un code couleur et vérifiez
android:src="@drawable/foodx_restaurant_logo"
remplacez cette image
merci mais cela ne fonctionne pas le problème est Erreur de gonflage de la classe TextView
Avez-vous essayé ces solutions supprimer l'image d'ImageView car l'exception provient d'un autre problème plus profond dans votre mise en page qui est ensuite enveloppé dans une InflateException
Veuillez également changer dans toute la mise en page margin
définie avec sp
en dp
, principalement utilisé sp
pour android: textSize
oui je le sais mais ça ne me posera pas ce problème que je reçois maintenant
@VipulChauhan essayez juste une fois de supprimer toutes les images utilisées et setColor, j'ai essayé cela et cela fonctionne parfaitement
Il y a un problème avec andrpid Q, quelque chose avec le chargement de la police de texte parfois, Dans votre stacktrace aussi je peux voir le problème, si vous utilisez un fichier de police personnalisé, vérifiez-le, si vous n'utilisez aucune police, importez un le fichier de police que vous prenez en charge dans votre projet, de sorte que s'il ne l'obtient pas depuis os, il peut l'obtenir à partir de l'asset. Vérifiez le lien ci-dessous
Crash lors de l'utilisation de la police ttf intégrée sur Android 10 / Android Q
merci pour votre réponse, mais comme ci-dessus, vous pouvez voir que je n'utilise pas la famille de polices pour ma vue texte
ok au fait pouvez-vous essayer en ajoutant la ligne ci-dessous dans chaque textview android: fontFamily = "sans-serif"
Selon votre xml, l'erreur pointe vers Textview et elle est liée à certains détails de textview.
Je pense que le problème est que le colorPrimaryText
n'est pas défini correctement. Veuillez vous assurer que cette propriété est correctement définie.
J'ai essayé d'exécuter votre code dans Android 10 et cela fonctionne bien.
Veuillez vérifier et essayer cette solution.
J'espère que cela résoudra votre problème.
Publiez votre
LoginActivity.java
@SaurabhThorat Il me montre trop d'erreur de code donc je ne suis pas en mesure de télécharger le fichier java
@VipulChauhan qu'est-ce que la couleur colorPrimaryText?. pouvez-vous s'il vous plaît montrer quel est le code dans colors.xml
Ajoutez le code autour de la ligne 76 de votre
LoginActivity.java