gpt4 book ai didi

java - Android InflateException FloatingActionButton

转载 作者:行者123 更新时间:2023-12-02 11:47:17 25 4
gpt4 key购买 nike

我有 recyclerview 项目,我正在尝试编辑它们的外观。我尝试向 recyclerview 的每个项目添加一个 float 操作按钮,但它引发了此错误:

android.view.InflateException: Binary XML file line #0: Error inflating class <unknown>

每个 RecyclerView 项目的设计如下:

<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/constraintLayout"
android:layout_width="match_parent"
android:layout_height="@dimen/list_item_height"
android:layout_marginLeft="@dimen/margin_medium"
android:layout_marginRight="@dimen/margin_medium"
android:gravity="center_vertical">

<ImageView
android:id="@+id/shoeImage"
android:adjustViewBounds="true"
android:scaleType="centerCrop"
android:layout_width="64dp"
android:layout_height="match_parent"
app:srcCompat="@drawable/air" />

<TextView
android:id="@+id/textBrandName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="16dp"
android:text="..."
android:textColor="@color/common_google_signin_btn_text_dark_focused"
app:layout_constraintHorizontal_bias="0.504"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<TextView
android:id="@+id/textShoeName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:text="..."
android:textColor="@color/common_google_signin_btn_text_dark_focused"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintHorizontal_bias="0.504"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.698" />

<android.support.design.widget.FloatingActionButton
android:id="@+id/floatingActionButton2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="top|bottom|end"
android:layout_marginStart="8dp"
android:clickable="true"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toEndOf="@+id/textBrandName"
app:layout_constraintTop_toTopOf="parent" />

</android.support.constraint.ConstraintLayout>

注意...在添加 FloatingActionButton 代码之前一切正常。可能是什么问题呢? FAB 按钮没有图像,因此无法加载任何太大的可绘制对象。谢谢!

最佳答案

将其编译到您的 build.gradle 文件中:

compile 'com.android.support:design:23.3.0'
compile 'com.android.support.constraint:constraint-layout:1.0.2'

关于java - Android InflateException FloatingActionButton,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48107289/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com