簡體   English   中英

二進制 XML 文件第 10 行:為 API 級別 19 增加類 com.google.android.material.button.MaterialButton 時出錯

[英]Binary XML file line #10: Error inflating class com.google.android.material.button.MaterialButton for API Level 19

實現 'com.google.android.material: material: 1.0.0'

但是當我在設備上運行 api19 時,我在標題中收到錯誤消息。

為了這:

<style name = "Theme.MyApp" parent = "Theme.MaterialComponents.Light">
<style name = "Theme.MyApp" parent = "Theme.MaterialComponents.Light.Bridge">

我嘗試了這些方法,但沒有得到結果。 我該如何解決這個問題?

在其他android版本中,沒有問題。

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">
    <com.google.android.material.button.MaterialButton
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/google_login_button"
        app:icon="@drawable/google"
        app:layout_constraintStart_toStartOf="@+id/guideline"
        app:layout_constraintHorizontal_bias="0.5"
        app:layout_constraintEnd_toStartOf="@+id/facebook_login_button"
        app:layout_constraintHorizontal_chainStyle="spread_inside"
        app:layout_constraintTop_toTopOf="@+id/facebook_login_button"
        app:layout_constraintBottom_toBottomOf="@+id/facebook_login_button"
        android:text="@string/google_button_text" app:cornerRadius="@dimen/login_screen_button_radius"/>

<com.google.android.material.button.MaterialButton
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/facebook_login_button"
        app:icon="@drawable/facebook"
        app:layout_constraintStart_toEndOf="@+id/google_login_button"
        app:layout_constraintHorizontal_bias="0.5"
        app:layout_constraintEnd_toStartOf="@+id/twitter_login_button"
        app:layout_constraintBottom_toBottomOf="parent"
        android:layout_marginBottom="8dp"
        android:text="@string/facebook_button_text" android:layout_marginStart="8dp"
        android:layout_marginEnd="8dp" app:cornerRadius="@dimen/login_screen_button_radius"/>

<com.google.android.material.button.MaterialButton
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/twitter_login_button"
        app:icon="@drawable/twitter"
        app:layout_constraintEnd_toStartOf="@+id/guideline2"
        app:layout_constraintStart_toEndOf="@+id/facebook_login_button"
        app:layout_constraintHorizontal_bias="0.5"
        android:layout_marginEnd="8dp"
        app:layout_constraintBottom_toBottomOf="@+id/facebook_login_button"
        app:layout_constraintTop_toTopOf="@+id/facebook_login_button"
        android:text="@string/twitter_button_text" app:cornerRadius="@dimen/login_screen_button_radius"/>

我知道這有點晚了,但對於那些將來會遇到這個問題的人來說。 將您的 AppTheme 父項更改為 Theme.MaterialComponents

<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
    <!-- Customize your theme here. -->
</style>

<!-- Material application theme. -->
<style name="AppTheme" parent="Theme.MaterialComponents.Light.DarkActionBar">
    <!-- Customize your theme here. -->
</style>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM