skip to Main Content

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


  1. For Material style you need to use Material components.
    com.google.android.material.button.MaterialButton

    Login or Signup to reply.
  2. Go to themes and change the parent element of your style to:

    Login or Signup to reply.
  3. 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.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search