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
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
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
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.
Related
I'm seeing the following exception in crash logs:
android.app.RemoteServiceException: Bad notification posted from package XXX: Couldn't inflate contentViewsandroid.view.InflateException: Binary XML file line #2: Binary XML file line #2: Error inflating class com.google.android.material.appbar.AppBarLayout
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1797)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:176)
at android.app.ActivityThread.main(ActivityThread.java:6651)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:547)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:824)
But, my custom notification layout has never defined this class label:com.google.android.material.appbar.AppBarLayout
Moreover, my custom layout:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/root"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/local_push_bg_color"
android:orientation="vertical"
android:padding="#dimen/dp_6">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="#dimen/dp_26">
<TextView
android:id="#+id/tv_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:drawableStart="#drawable/ic_local_push_logo"
android:drawablePadding="#dimen/dp_6"
android:maxLines="1"
android:textStyle="bold"
android:textColor="#color/local_push_title_text_color"
android:text="#string/local_push_title"
android:textSize="#dimen/sp_14"
tools:ignore="RelativeOverlap" />
<ImageView
android:id="#+id/iv_next"
android:layout_width="#dimen/dp_26"
android:layout_height="match_parent"
android:layout_alignParentEnd="true"
android:layout_centerVertical="true"
android:src="#drawable/ic_local_push_next"
tools:ignore="ContentDescription" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/v_content"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_marginTop="#dimen/dp_10"
android:layout_weight="1">
<ImageView
android:id="#+id/iv_push_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="fitXY"
tools:ignore="ContentDescription" />
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/shape_bg_local_push_content" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:src="#drawable/ic_local_push_play" />
<TextView
android:id="#+id/tv_push_content_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_margin="#dimen/dp_10"
android:ellipsize="end"
android:textStyle="bold"
android:maxLines="2"
tools:text="asdaksjdllasfjasldjkasfljkaslkfjlsjafsafjk"
android:textColor="#color/c_white"
android:textSize="#dimen/sp_14" />
</RelativeLayout>
<LinearLayout
android:id="#+id/v_search_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="#dimen/dp_10"
android:background="#drawable/shape_bg_local_push_search"
android:orientation="horizontal"
android:padding="#dimen/dp_8">
<TextView
android:id="#+id/tv_push_search_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:drawableStart="#drawable/ic_local_push_search"
android:drawablePadding="#dimen/dp_6"
android:ellipsize="end"
android:maxLines="1"
tools:text="what the fk"
android:textColor="#color/local_push_search_text_color"
android:textSize="#dimen/sp_12" />
</LinearLayout>
</LinearLayout>
as you see, There is no class label reported above.
So far, we have found three different error messages for the same
custom notification layout:
Error inflating class com.google.android.material.appbar.AppBarLayout
Error inflating class android.support.design.widget.AppBarLayout
Error inflating class android.widget.TextView
I am getting error in inflating a view in recycler view. It works on Oreo and Pie but not working in Nougat and devices below it.
This is the code I have used to inflating the view.
View itemView = LayoutInflater.from(parent.getContext())
.inflate(R.layout.listing_row_item, parent, false);
My xml file is
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/outlined_blue_rectangle"
android:clickable="true"
android:focusable="true"
android:orientation="vertical"
android:layout_marginBottom="#dimen/row_padding"
android:paddingBottom="#dimen/contentPadding"
android:paddingStart="#dimen/contentPadding"
android:paddingEnd="#dimen/contentPadding"
android:paddingTop="#dimen/contentPadding">
<LinearLayout
android:id="#+id/ll_name"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="0dp"
android:layout_weight="1"
android:text="Name"
android:layout_height="wrap_content"
android:textColor="#color/blackColor"
android:textSize="#dimen/textSizeMedium" />
<TextView
android:id="#+id/name"
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:textColor="#color/blackColor"
android:textSize="#dimen/textSizeMedium" />
</LinearLayout>
<LinearLayout
android:id="#+id/ll_status"
android:layout_below="#+id/ll_name"
android:layout_marginTop="#dimen/verticalSpacing"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="0dp"
android:layout_weight="1"
android:text="Loan Application Status"
android:layout_height="wrap_content"
android:textColor="#color/blackColor"
android:textSize="#dimen/textSizeMedium" />
<TextView
android:id="#+id/status"
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:textColor="#color/blackColor"
android:textSize="#dimen/textSizeMedium" />
</LinearLayout>
<LinearLayout
android:id="#+id/ll_eligibility"
android:layout_below="#+id/ll_status"
android:layout_marginTop="#dimen/verticalSpacing"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:text="Eligibility Status"
android:textColor="#color/blackColor"
android:textSize="#dimen/textSizeMedium" />
<TextView
android:id="#+id/preliminary_eligibility"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:textColor="#color/blackColor"
android:textSize="#dimen/textSizeMedium" />
</LinearLayout>
**<Button**
android:id="#+id/check_eligibility"
android:layout_below="#+id/ll_eligibility"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="#dimen/verticalSpacing"
android:paddingStart="#dimen/row_padding"
android:paddingEnd="#dimen/row_padding"
android:text="Check\nEligibility"
android:layout_alignParentEnd="true"
android:textAllCaps="false"
android:background="#drawable/button_selection_selected"
android:textColor="#color/whiteColor"
android:textSize="#dimen/textSizeSmall" />
<Button
android:id="#+id/all_info"
android:layout_below="#+id/ll_eligibility"
android:layout_marginTop="#dimen/verticalSpacing"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingStart="#dimen/row_padding"
android:paddingEnd="#dimen/row_padding"
android:text="All\nInfo"
android:textAllCaps="false"
android:background="#drawable/button_selection_selected"
android:textColor="#color/whiteColor"
android:textSize="#dimen/textSizeSmall"/>
</RelativeLayout>
The error message I am getting
android.view.InflateException: Binary XML file line #88: Binary XML file line #88: Error inflating class Button
Caused by: android.view.InflateException: Binary XML file line #88: Error inflating class Button
Caused by: java.lang.ArrayIndexOutOfBoundsException: length=31; index=464
at android.content.res.StringBlock.get(StringBlock.java:65)
at android.content.res.XmlBlock$Parser.getPooledString(XmlBlock.java:458)
at android.content.res.TypedArray.loadStringValueAt(TypedArray.java:1212)
at android.content.res.TypedArray.getString(TypedArray.java:202)
at android.widget.TextView.<init>(TextView.java:1100)
at android.widget.Button.<init>(Button.java:109)
at android.widget.Button.<init>(Button.java:105)
at androidx.appcompat.widget.AppCompatButton.<init>(AppCompatButton.java:71)
at androidx.appcompat.widget.AppCompatButton.<init>(AppCompatButton.java:67)
If you are using layout that only supports API level 25+, you should put it inside a res/layout-v25 folder (create the folder if it doesn't exist), and you must create a substitute layout for API level 24 below inside res/layout folder.
Android will automatically use layout-v25 on API level 25+.
I have the following XML file:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
tools:context="com.ad123.oshikwanyamadictionary.EditorActivity"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="7dp"
app:layout_behavior="#string/appbar_scrolling_view_behavior">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:text="term in question"
android:textSize="20sp"
android:paddingTop="3dp"
android:paddingStart="3dp"
android:paddingLeft="3dp"
android:paddingBottom="10dp"
android:gravity="center_horizontal"
android:id="#+id/term_in_question"/>
<AutoCompleteTextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textCapSentences"
android:hint="#string/translation_suggestion"
android:id="#+id/suggestion_edit_text"
/>
<Spinner
android:paddingTop="10dp"
android:paddingLeft="3dp"
android:paddingStart="3dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/language_report_spinner">
</Spinner>
<!--android:entries="#array/sourceLanguage"
android:entries="#array/wordType"-->
<Spinner
android:paddingTop="15dp"
android:paddingLeft="3dp"
android:paddingStart="3dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/word_type_spinner"
android:visibility="gone">
</Spinner>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:inputType="textCapSentences"
android:id="#+id/term_plural_edit_text"
android:hint="#string/plural_of_term_contribution"
android:visibility="gone"/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:inputType="textCapSentences"
android:visibility="gone"
android:id="#+id/translation_plural_edit_text"
android:hint="#string/plural_of_translation_contribution"/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:visibility="gone"
android:id="#+id/term_example_edit_text"
android:hint="#string/example_using_term_contribution"/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:inputType="textCapSentences"
android:visibility="gone"
android:id="#+id/translation_example_edit_text"
android:hint="#string/example_using_translation_contrinution"/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:inputType="textCapSentences"
android:visibility="gone"
android:id="#+id/alternative"
android:hint="#string/alternative_edit_text"/>
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:id="#+id/send_data"
android:text="#string/send_data"
android:backgroundTint="#color/Button"/>
<ProgressBar
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_gravity="center_horizontal"
android:layout_margin="5dp"
android:visibility="gone"
android:id="#+id/progress_bar_edit"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/or_edit_choose"/>
</LinearLayout>
Now if I try to preview it, it throws the following exception:
java.lang.ArrayIndexOutOfBoundsException: 16
at android.text.StaticLayout.generate(StaticLayout.java:854)
at android.text.StaticLayout.<init>(StaticLayout.java:603)
at android.text.StaticLayout.<init>(StaticLayout.java:50)
at android.text.StaticLayout$Builder.build(StaticLayout.java:425)
at android.widget.TextView.makeNewLayout(TextView.java:8272)
at android.widget.TextView.assumeLayout(TextView.java:8104)
at android.widget.TextView.onPreDraw(TextView.java:6742)
at android.view.ViewTreeObserver.dispatchOnPreDraw(ViewTreeObserver.java:977)
at android.view.AttachInfo_Accessor.dispatchOnPreDraw(AttachInfo_Accessor.java:46)
at com.android.layoutlib.bridge.impl.RenderSessionImpl.renderAndBuildResult(RenderSessionImpl.java:404)
at com.android.layoutlib.bridge.impl.RenderSessionImpl.renderAndBuildResult(RenderSessionImpl.java:543)
at com.android.layoutlib.bridge.impl.RenderSessionImpl.render(RenderSessionImpl.java:426)
at com.android.layoutlib.bridge.BridgeRenderSession.render(BridgeRenderSession.java:108)
at com.android.ide.common.rendering.api.RenderSession.render(RenderSession.java:154)
at com.android.ide.common.rendering.api.RenderSession.render(RenderSession.java:136)
at com.android.tools.idea.rendering.RenderTask.lambda$renderInner$5(RenderTask.java:671)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
I have already tried to clean the project and also change the target api of the preview, but nothing seems to help. At the same time I get an error for only one string. It is the string used in the last TextView: #String/or_edit_choose. Although it is translated to all languages, it still gives me the error message: "or_edit_choose is translated here but not in default locale". The thing is, that the error message is shown to me in the default strings.xml file, which should be the default locale. I do not know if the errors are connected, but they both showed up at the same time. There was also a brief moment, where the string could be accessed from another layout file, just not from the one given above. Now it cannot be accessed from any file.
In strings.xml add this line
tools:ignore="ExtraTranslation" xmlns:tools="http://schemas.android.com/tools"
to <resources> tag
like this
<resources tools:ignore="ExtraTranslation" xmlns:tools="http://schemas.android.com/tools">
Apparently the tag android:visibility="gone" caused the rendering to be impossible. After I changed it to visible in the xml, to change it in the java file to the values needed, the rendering worked without a problem. I have no idea though, why this might be affecting the rendering.
This is the main activity of xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/background"
tools:context="com.example.liew.idelivery.MainActivity">
<LinearLayout
android:orientation="vertical"
android:layout_centerInParent="true"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:layout_width="match_parent"
android:layout_height="250dp"
android:layout_gravity="center"
android:src="#drawable/logo" />
<TextView
android:id="#+id/txtSlogan"
android:layout_width="match_parent"
android:layout_height="100dp"
android:gravity="center"
android:text="#string/slogan"
android:textAlignment="center"
android:textColor="#android:color/white"
android:textSize="18sp"
android:textStyle="italic" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_alignParentBottom="true"
android:weightSum="2"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<info.hoang8f.widget.FButton
android:id="#+id/btnSignUp"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_margin="8dp"
android:layout_weight="1"
android:text="Sign Up"
android:textColor="#android:color/white"
app:buttonColor="#color/btnSignUp"
app:cornerRadius="4dp"
app:shadowColor="#android:color/black"
app:shadowEnabled="true"
app:shadowHeight="5dp" />
<info.hoang8f.widget.FButton
android:id="#+id/btnSignIn"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_margin="8dp"
android:layout_weight="1"
android:text="Sign In"
android:textColor="#android:color/white"
app:buttonColor="#color/btnSignUp"
app:cornerRadius="4dp"
app:shadowColor="#android:color/black"
app:shadowEnabled="true"
app:shadowHeight="5dp" />
</LinearLayout>
And this is the error that i found in my logcat.
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.liew.idelivery, PID: 18266
java.lang.RuntimeException: Unable to start activity
ComponentInfo{com.example.liew.idelivery/com.example.liew.idelivery.MainActivit
y}: android.view.InflateException: Binary XML file line #43: Error inflating
class info.hoang8f.widget.FButton
at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2462)
at
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2534)
at android.app.ActivityThread.access$900(ActivityThread.java:164)
I think the error occurred as there is no closing tag for RelativeLayout. If the problem still persists try to attach the MainActivity file as well, I'll check it.
One last suggestion: Try to use ConstraintLayout instead of LinearLayout and RelativeLayout :)
android.view.InflateException: Binary XML file line #43: Error inflating class
Exception arise only there are something wrong in xml file first of all your xml files need to close with the tag
</RelativeLayout>
Other possibility is that custom views which are you using, make sure the views are on the correct path (package name exist with the path)
info.hoang8f.widget.FButton
I am having some issues with a custom layout (ToDoView is extending TableLayout), and I do not know how to make sure it is under everything else (by everything else, I mean the EditText, and the Buttons).
As of right now, my app crashes with:
12-18 07:11:13.886: E/AndroidRuntime(3228):
java.lang.RuntimeException: Unable to start activity
ComponentInfo{com.parrishb.todo/com.parrishb.todo.ToDoActivity}:
android.view.InflateException: Binary XML file line #44: Error
inflating class com.parrishb.todo.ToDoView
Here is the xml file:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/rl"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".ToDoActivity" >
<EditText
android:id="#+id/myEditText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:contentDescription="#string/addItemContentDescription"
android:hint="#string/addItemHint" />
<Button
android:id="#+id/pickDate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#id/myEditText"
android:text="Change the Date" />
<Button
android:id="#+id/pickTime"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_below="#id/myEditText"
android:layout_toRightOf="#id/pickDate"
android:text="Change the Time" />
<DatePicker
android:id="#+id/datePicker"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TimePicker
android:id="#+id/timePicker"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<com.parrishb.todo.ToDoView
android:id="#+id/tdv"
class="com.parrishb.todo.ToDoView"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_below="#id/datePicker"
/>
</RelativeLayout>
Any help would be great!
I realized that in my ToDoView class, I was missing the constructor:
public ToDoView(Context c, AtrributeSet as){
super(c, as);
//...
}
Found at https://stackoverflow.com/a/3739853/1888585