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?
3
Answers
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.
So whatever is missing, just fill it in in your theme files.