Home > Software design >  Render Problem Occurs when trying to use TextInputLayout in Android Studio
Render Problem Occurs when trying to use TextInputLayout in Android Studio

Time:06-14

Ok, So first of All, I would like to clear a confusion, I know there are some similar Questions on StackOverflow but unfortunately they didn't helped and there were a bit different from my case too..

So, Basically I am trying to Create a Unit Converter App, And i am using the TextInputLayout dropdown to let the user pick what unit they would like to pick, now there are two cases where I am using TextInputLayout

  1. To ask the user to pick the unit which they would like to Convert From
  2. To ask the user to pick the unit which they would like to Convert To

and in that whenever I try to use TextInputLayout I Get a Render Problem Error on Android Studio

Screenshot of the Error enter image description here

Now, If I try to remove the TextInputLayout The Render Problem Disappears As you can see in the below Screenshot enter image description here

Stack Trace of The Error -

java.lang.IllegalArgumentException: width and height must be > 0
at android.graphics.Bitmap.createBitmap(Bitmap.java:1113)
at android.graphics.Bitmap.createBitmap(Bitmap.java:1080)
at android.graphics.Bitmap.createBitmap(Bitmap.java:1030)
at android.graphics.Bitmap.createBitmap(Bitmap.java:991)
at com.google.android.material.textfield.CutoutDrawable.drawStrokeShape(CutoutDrawable.java:100)
at com.google.android.material.shape.MaterialShapeDrawable.draw(MaterialShapeDrawable.java:974)
at com.google.android.material.textfield.CutoutDrawable.draw(CutoutDrawable.java:89)
at android.graphics.drawable.LayerDrawable.draw(LayerDrawable.java:1018)
at android.view.View.drawBackground(View.java:22581)
at android.view.View.draw_Original(View.java:22342)
at android.view.View_Delegate.draw(View_Delegate.java:56)
at android.view.View.draw(View.java:22323)
at android.view.View.draw_Original(View.java:22223)
at android.view.View_Delegate.draw(View_Delegate.java:68)
at android.view.View.draw(View.java:21995)
at android.view.ViewGroup.drawChild(ViewGroup.java:4516)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4277)
at android.view.View.draw_Original(View.java:22221)
at android.view.View_Delegate.draw(View_Delegate.java:68)
at android.view.View.draw(View.java:21995)
at android.view.ViewGroup.drawChild(ViewGroup.java:4516)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4277)
at android.view.View.draw_Original(View.java:22353)
at android.view.View_Delegate.draw(View_Delegate.java:56)
at android.view.View.draw(View.java:22323)
at com.google.android.material.textfield.TextInputLayout.draw(TextInputLayout.java:4078)
at android.view.View.draw_Original(View.java:22223)
at android.view.View_Delegate.draw(View_Delegate.java:68)
at android.view.View.draw(View.java:21995)
at android.view.ViewGroup.drawChild(ViewGroup.java:4516)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4277)
at androidx.constraintlayout.widget.ConstraintLayout.dispatchDraw(ConstraintLayout.java:1994)
at android.view.View.draw_Original(View.java:22221)
at android.view.View_Delegate.draw(View_Delegate.java:68)
at android.view.View.draw(View.java:21995)
at android.view.ViewGroup.drawChild(ViewGroup.java:4516)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4277)
at android.view.View.draw_Original(View.java:22353)
at android.view.View_Delegate.draw(View_Delegate.java:56)
at android.view.View.draw(View.java:22323)
at android.widget.ScrollView.draw(ScrollView.java:1833)
at android.view.View.draw_Original(View.java:22223)
at android.view.View_Delegate.draw(View_Delegate.java:68)
at android.view.View.draw(View.java:21995)
at android.view.ViewGroup.drawChild(ViewGroup.java:4516)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4277)
at androidx.constraintlayout.widget.ConstraintLayout.dispatchDraw(ConstraintLayout.java:1994)
at android.view.View.draw_Original(View.java:22221)
at android.view.View_Delegate.draw(View_Delegate.java:68)
at android.view.View.draw(View.java:21995)
at android.view.ViewGroup.drawChild(ViewGroup.java:4516)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4277)
at android.view.View.draw_Original(View.java:22221)
at android.view.View_Delegate.draw(View_Delegate.java:68)
at android.view.View.draw(View.java:21995)
at android.view.ViewGroup.drawChild(ViewGroup.java:4516)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4277)
at android.view.View.draw_Original(View.java:22221)
at android.view.View_Delegate.draw(View_Delegate.java:68)
at android.view.View.draw(View.java:21995)
at android.view.ViewGroup.drawChild(ViewGroup.java:4516)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4277)
at android.view.View.draw_Original(View.java:22353)
at android.view.View_Delegate.draw(View_Delegate.java:56)
at android.view.View.draw(View.java:22323)
at com.android.layoutlib.bridge.impl.RenderSessionImpl.renderAndBuildResult(RenderSessionImpl.java:553)
at com.android.layoutlib.bridge.impl.RenderSessionImpl.render(RenderSessionImpl.java:450)
at com.android.layoutlib.bridge.BridgeRenderSession.render(BridgeRenderSession.java:120)
at com.android.ide.common.rendering.api.RenderSession.render(RenderSession.java:137)
at com.android.ide.common.rendering.api.RenderSession.render(RenderSession.java:119)
at com.android.tools.idea.rendering.RenderTask.lambda$null$12(RenderTask.java:992)
at com.android.tools.idea.rendering.RenderExecutor$runAsyncActionWithTimeout$2.run(RenderExecutor.kt:174)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:834)

XML of Convert From Dropdown

<com.google.android.material.textfield.TextInputLayout
            android:id="@ id/textInputLayout2"
            style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox.ExposedDropdownMenu"
            android:layout_width="250dp"
            android:layout_height="wrap_content"
            android:layout_marginTop="20dp"
            android:hint="@string/convert_from"
            app:boxCornerRadiusBottomEnd="100dp"
            app:boxCornerRadiusBottomStart="100dp"
            app:boxCornerRadiusTopEnd="100dp"
            app:boxCornerRadiusTopStart="100dp"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toBottomOf="@ id/textView">

            <AutoCompleteTextView
                android:id="@ id/convertFromAutoCompleteTextView"
                android:layout_width="250dp"
                android:layout_height="match_parent"
                android:layout_weight="1"
                android:fontFamily="@font/poppins_medium"
                android:inputType="none"
                android:text="@string/kilogram_kg" />

        </com.google.android.material.textfield.TextInputLayout>

Convert To Dropdown XML -

<com.google.android.material.textfield.TextInputLayout
            android:id="@ id/textInputLayout3"
            style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox.ExposedDropdownMenu"
            android:layout_width="250dp"
            android:layout_height="wrap_content"
            android:layout_marginTop="10dp"
            android:hint="@string/convert_to"
            app:boxCornerRadiusBottomEnd="100dp"
            app:boxCornerRadiusBottomStart="100dp"
            app:boxCornerRadiusTopEnd="100dp"
            app:boxCornerRadiusTopStart="100dp"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toBottomOf="@ id/textInputLayout2">

            <AutoCompleteTextView
                android:id="@ id/convertToAutoCompleteTextView"
                android:layout_width="250dp"
                android:layout_height="match_parent"
                android:layout_weight="1"
                android:fontFamily="@font/poppins_medium"
                android:inputType="none"
                android:text="@string/gram_g" />

        </com.google.android.material.textfield.TextInputLayout>

Things I Tried Doing..

  1. Rebuilding The Project
  2. Restarting the Android Studio
  3. Invalidating the Cache and Restarting
  4. Refreshing the Layout (Which was Suggested By Android Studio )

That's All I tried to Include everything which may help in Answering this Question but still if you need something, then please ask in the Replies :))

Thank You!

CodePudding user response:

Are you define your Adpater & unit List properly?

CodePudding user response:

you may also check this repository 

https://github.com/shaidazmin/AutoCompleteTextView
  • Related