android - 1-加载 AppCompat ActionBar 失败,出现未知错误。2-在当前主题中找不到样式“floatingActionButtonStyle”
问题描述
1-加载 AppCompat ActionBar 失败,出现未知错误。
2-在当前主题中找不到样式“floatingActionButtonStyle”。
XML 文件显示上述两个错误以及以下内容 -
1-缺少样式。是否为此布局选择了正确的主题?使用布局上方的主题组合框选择不同的布局,或修复主题样式引用。
2-无法实例化以下类:- android.support.v7.widget.ActionBarContainer
- android.support.v7.widget.ActionBarContextView
- android.support.v7.app.WindowDecorActionBar
- android.support.design.widget.TextInputLayout
类路径是:
classpath 'com.android.tools.build:gradle:3.1.3'
classpath 'com.google.gms:google-services:4.0.2'
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0-beta01'
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
//add library
implementation 'com.android.support:design:28.0.0-beta01'
implementation 'com.firebaseui:firebase-ui-database:4.1.0'
}
apply plugin: 'com.google.gms.google-services
XML 文件 -
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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:id="@+id/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="16dp"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:paddingTop="16dp"
tools:context=".MainActivity">
<android.support.design.widget.FloatingActionButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:clickable="true"
android:focusable="true"
android:src="@drawable/ic_send"
android:id="@+id/fab"
android:tint="@android:color/white"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
app:fabSize="mini"
/>
<android.support.design.widget.TextInputLayout
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:layout_toLeftOf="@+id/fab"
android:layout_alignParentBottom="true"
android:layout_toStartOf="@+id/fab"
android:layout_alignParentStart="true"
android:layout_alignParentLeft="true"
>
<EditText
android:id="@+id/input"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Message..."
android:inputType="text" />
</android.support.design.widget.TextInputLayout>
<ListView
android:id="@+id/list_of_message"
android:layout_alignParentTop="true"
android:layout_alignParentStart="true"
android:layout_above="@+id/fab"
android:dividerHeight="16dp"
android:divider="@android:color/transparent"
android:layout_marginBottom="16dp"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentLeft="true">
</ListView>
</RelativeLayout>
解决方案
粘贴这两个依赖项
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:design:28.0.0'
代替
implementation 'com.android.support:design:28.0.0-beta01'
implementation 'com.android.support:appcompat-v7:28.0.0-beta01'
测试版导致问题。
推荐阅读
- python - Django返回不同的图像
- deepsecurity - 趋势科技服务器深度安全防护系统 12 内的应用程序控制中的一台计算机的维护模式
- xml - XML - 按名称查找具有特定值的属性的节点
- python - Pandas:根据另一列的映射值创建新列
- tensorflow - 为什么embed_input的形状是1000?
- javascript - 在对话框流中使用 if 条件不起作用
- swift - 前提条件失败:从 iOS 13.4 开始在 SwiftUI 中使用 GeometryReader 时输入索引无效
- html - 来自 API 的 HTML 标签
- stm32 - 重新节点,“按下”一个按钮并“看到”一个 LED 灯
- arrays - 如果重复 0 或 n 次,则找到可以产生两个给定字符串的最小字符串 x