activity_login.xml

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
    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"
    tools:context=".Login">


    <TextView
        android:id="@+id/textView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginStart="8dp"
        android:layout_marginTop="40dp"
        android:layout_marginEnd="8dp"
        android:fontFamily="sans-serif-black"
        android:text="LogIn"
        android:textColor="#641FE4"
        android:textSize="25sp"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.502"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

    Material Button
    <com.google.android.material.button.MaterialButton
        android:id="@+id/button"
        android:layout_width="123dp"
        android:layout_height="50dp"
        android:layout_marginStart="8dp"
        android:layout_marginTop="8dp"
        android:layout_marginEnd="8dp"
        android:layout_marginBottom="32dp"
        android:fontFamily="sans-serif-black"
        android:text="Go!"
        android:textAllCaps="false"
        android:backgroundTint="#203377"
        android:textSize="17sp"
        app:cornerRadius="20dp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/textInputLayout2"
        app:layout_constraintVertical_bias="0.113"
        app:rippleColor="#03A9F4" />



</androidx.constraintlayout.widget.ConstraintLayout>


这是布局文件。当我添加另一个按钮时,会导致渲染问题。当我重新启动Studio时,它不会引发错误,但是在构建后会引发异常java.lang.ClassCastException@b46a6ec

最佳答案

检查是否已添加材料设计库。

10-04 23:10