gpt4 book ai didi

android - 膨胀类 android.support.design.widget.FloatingActionButton 时出错 - android

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

我想运行我的 Activity 我遇到了这个错误:

android.view.InflateException: Binary XML file line #21: Error inflating class android.support.design.widget.FloatingActionButton
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2693)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2758)
at android.app.ActivityThread.access$900(ActivityThread.java:177)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1448)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:5942)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1389)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1184)
Caused by: android.view.InflateException: Binary XML file line #21: Error inflating class android.support.design.widget.FloatingActionButton

我的 xml 代码:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/white">

<ListView
android:id="@+id/listview_diary"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipToPadding="false"
android:divider="@null"
android:dividerHeight="16dp"
android:fadingEdge="none"
android:fitsSystemWindows="true"
android:padding="12dp"
android:scrollbars="none"
android:background="@android:color/white"/>

<android.support.design.widget.FloatingActionButton
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/fab_add_diary"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_margin="16dp"
android:clickable="true"
android:padding="8dp"
android:src="@mipmap/ic_add"
app:backgroundTint="@color/colorPrimary"
app:borderWidth="0dp"/>

</RelativeLayout>

我的类扩展了一个 AppCompatActivity 类。

我的风格:

 <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">

我的 Gradle :

apply plugin: 'com.android.application'

android {
compileSdkVersion 24
buildToolsVersion "25.0.0"

defaultConfig {
applicationId "***.***.***"
minSdkVersion 16
targetSdkVersion 24
versionCode 1
versionName "1.0"
jackOptions {
enabled true
}
// Enabling multidex support.
multiDexEnabled true
}
buildTypes {
release {
debuggable false
minifyEnabled false
shrinkResources false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
dexOptions {
javaMaxHeapSize "2g"
incremental true
preDexLibraries = false
}
}
repositories {
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
maven { url 'https://raw.github.com/felipecsl/m2repository/master' }
// maven { url "https://jitpack.io" }
mavenCentral()

}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile('com.github.florent37:materialviewpager:1.2.0@aar') {
transitive = true
}
compile 'com.android.support:appcompat-v7:24.2.1'
compile 'com.android.support:recyclerview-v7:24.0.0'
compile 'com.android.support:design:24.0.0'
compile 'com.android.support:multidex:1.0.1'
compile 'com.android.support:cardview-v7:24.0.0'
compile 'com.android.support:support-v4:24.0.0'
...

最佳答案

试试这个
1.使用安装最新版本的 sdk 管理器更新设计支持库和 appCompat 库。
2.使用Appcompat主题。
3. 从 AppCompatActivity 而不是 Activity 扩展您的 Activity。
4.尽量保持两个库的版本一致

compile 'com.android.support:appcompat-v7:24.2.0'
compile 'com.android.support:design:24.2.0'

5.在所有这些清理你的项目并运行之后。

关于android - 膨胀类 android.support.design.widget.FloatingActionButton 时出错 - android,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40484909/

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