Reputation: 11
This is my layout:-
<?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>
These are my logs:-
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)
I am unable to get the problems but I have checked all my libraries are up to date, Clean project and also invalidate and restart my studio.
Note:- Devices till android 9 are working fine with the same code but android 10 is giving me error
Upvotes: 1
Views: 2049
Reputation: 1601
As per your xml the error points to Textview and it is related to some of the details in textview.
I think the problem is that the colorPrimaryText
is not set properly. Please make sure that this property is set properly .
I have tried running your code in android 10 and it works fine.
Please do check and try this solution.
Hope this will resolve your issue.
Upvotes: 0
Reputation: 1138
There is an issue with andrpid Q, something with text font loading sometimes, In your stacktrace too I can see the issue, If you are using any custom font file check it, If you are not using any font, then import a font file u are supporting in your project , so that If it s does not get it from os, It can get it from asset. Check below link
Crash when using bundled ttf font on Android 10 / Android Q
Upvotes: 2
Reputation: 1670
I think your problem with ImageView
display image its larger than the screen try to replace by some color code and check
android:src="@drawable/foodx_restaurant_logo"
replace this image
Upvotes: 1