【问题标题】:Render Problem with layout file and preview布局文件和预览的渲染问题
【发布时间】:2019-07-05 13:16:26
【问题描述】:

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>

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

【问题讨论】:

  • 你能展示你的使用 AppCompatButton 的 xml 文件/类吗?

标签: android material-design android-appcompat


【解决方案1】:

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

【讨论】:

  • 我已经添加了库兄弟。
猜你喜欢
  • 1970-01-01
  • 2014-12-23
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多