My android sudio design editor don't render material TextInputLayouts. I already tried invalidate caches. Every other element is rendering correct also other material elements
<com.google.android.material.textfield.TextInputLayout
android:id="#+id/ti"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="20dp"
android:layout_marginEnd="30dp"
android:layout_marginBottom="20dp"
android:hint="#string/street_number">
<com.google.android.material.textfield.TextInputEditText
android:layout_width="match_parent"
android:layout_height="50dp"
android:inputType="text"
android:text="#{vm.user.streetnumber}" />
</com.google.android.material.textfield.TextInputLayout>
You have to change in build.gradle
implementation 'com.google.android.material:material:1.2.0-alpha02'
It seems newer versions are not rendered correctly.
See:how to solve render problem Path.op() not supported?
You need to change the theme in the layout builder to match the one of your app.
in my case Update Android Studio, problem fix
Show all warnings in XML and press to recommendation that wrapped with blue and press modern rendering feature and Restart Android Studio. You can switch off this feature.
Related
When I'm applying style to my button #style/Widget.Material3.Button then it is making the whole layout design disappear and the layout is not visible anymore.
Here is my XML Code.
<Button
style="#style/Widget.Material3.Button"
android:id="#+id/button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="60dp"
android:layout_marginTop="16dp"
android:layout_marginEnd="60dp"
android:text="Text"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/textField" />
Is there any solution to solve this render problem?
For Material style you need to use Material components.
com.google.android.material.button.MaterialButton
Go to themes and change the parent element of your style to:
Recently I got rendering problem too after updating from Android Studio Bumblebee into Android Studio Dolphin version 2021.3.1 patch 1 in the same project (nothing changed, no code changed and suddenly it just error rendering).
I used this style
style="#style/Widget.Material3.Button.Icon"
try the solution listed in this
Failed to find '#attr/shapeAppearanceSmallComponent' in current theme
in my case, I added this line in my theme files, because it caused rendering problem saying that it failed to find attr/textAppearanceLabelLarge in my current theme.
<item name="textAppearanceLabelLarge">#style/TextAppearance.Material3.LabelLarge</item>
So whatever is missing, just fill it in in your theme files.
Heyho mates,
currently I am learning the new layout editor of Android Studio with the new ConstraintLayout.
By the way, I hate it.
But I got the issue, that if I want to specify a layout_height with #dimen, it gets replaced with a dp value instead.
Someone else got this issue?
Android Studio version 2.2.2 & 2.2.3 same issue.
Newest gradle version.
Thanks in advance guys!
Edit :
Code example :
<?xml version="1.0" encoding="utf-8"?>
<ScrollView 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="wrap_content">
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:layout_width="wrap_content"
android:layout_height="#dimen/imageViewHeight"
app:srcCompat="#drawable/accept"
android:id="#+id/imageView"
android:layout_marginStart="16dp"
app:layout_constraintLeft_toLeftOf="parent"
android:layout_marginLeft="16dp"
android:layout_marginTop="16dp"
app:layout_constraintTop_toTopOf="parent" />
</android.support.constraint.ConstraintLayout>
</ScrollView>
Also happens outside scrollview.
Turns out this is a bug and will be fixed in Android Studio 2.3.
I think the reason behind this is, that ConstraintLayout as a WYSIWYG layout is inevitably meant to be edited/manipulated in the visual editor only.
Therefore keeping references to dimens in your dimens.xml would mean that as soon as you change something, move some elements around, these would not be relevant anymore and are hence replaced with "actual current values".
Also as mentioned in the docs:
All margins offered by the tool are factors of 8dp to help your views align to Material Design's 8dp square grid recommendations.
I create my own library with custom component in android. Component is very simple:
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:baselineAligned="true"/>
<EditText
android:id="#+id/edtExample"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="#string/simpleText"/>
</android.support.design.widget.TextInputLayout>
When i put it into android project it is working, but when i try this with custom component library it is not working. In debug i see that TextInputLayout haven't got a android.R.attr.state_focused when i click into EditText. It's a bug for TextInputLayout?
It's a bug in android support library. i notify google.
I'm using Eclipse and I just created a home page (menu) with 2 image buttons, but I am getting this error:
The graphics preview in the layout editor may not be accurate:
Paint.setShadowLayer is not supported.
What does it mean? And how can I solve it?
I am using API 21.
It means the preview doesn't know how to implement setShadowLayer. This means the preview won't look exactly like the result rendered on the device. Which is one of many reasons why you shouldn't trust the preview app- always test your layouts on a physical device before assuming they're done.
In my case it was a new component, a EditText with support of showing/hiding a password. It appeared in support library v.24.2.0. I mean:
<android.support.design.widget.TextInputLayout
android:id="#+id/password_input_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="0dp"
app:passwordToggleEnabled="true">
<android.support.design.widget.TextInputEditText
android:id="#+id/password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#android:color/transparent"
android:hint="#string/password"
android:inputType="textPassword"
tools:text="aaaaaaaaaaaaaaaaaaa"/>
</android.support.design.widget.TextInputLayout>
Of course, on a real device it is shown right (and in preview also).
As the first answer is true, but for fixing this issue you can try this (If you are using android studio) :
File > Invalidate Caches / Restart... > Invalidate and Restart
I'm using Eclipse and I just created a home page (menu) with 2 image buttons, but I am getting this error:
The graphics preview in the layout editor may not be accurate:
Paint.setShadowLayer is not supported.
What does it mean? And how can I solve it?
I am using API 21.
It means the preview doesn't know how to implement setShadowLayer. This means the preview won't look exactly like the result rendered on the device. Which is one of many reasons why you shouldn't trust the preview app- always test your layouts on a physical device before assuming they're done.
In my case it was a new component, a EditText with support of showing/hiding a password. It appeared in support library v.24.2.0. I mean:
<android.support.design.widget.TextInputLayout
android:id="#+id/password_input_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="0dp"
app:passwordToggleEnabled="true">
<android.support.design.widget.TextInputEditText
android:id="#+id/password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#android:color/transparent"
android:hint="#string/password"
android:inputType="textPassword"
tools:text="aaaaaaaaaaaaaaaaaaa"/>
</android.support.design.widget.TextInputLayout>
Of course, on a real device it is shown right (and in preview also).
As the first answer is true, but for fixing this issue you can try this (If you are using android studio) :
File > Invalidate Caches / Restart... > Invalidate and Restart