作者:xiaojin | 来源:互联网 | 2022-12-09 20:24
我在片段上添加了两个浮动操作按钮,但始终出现以下错误:
无效的drawable已添加到LayerDrawable!Drawable已经属于另一个所有者,但是没有公开恒定状态
可绘制-> ic_edit_account.xml
可绘制-> ic_home_account.xml
build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
defaultConfig {
applicationId "com.atta"
minSdkVersion 23
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support:design:26.1.0'
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'
// retrofit, gson
implementation 'com.google.code.gson:gson:2.6.2'
implementation 'com.squareup.okhttp3:okhttp:3.8.0'
implementation 'com.squareup.retrofit2:retrofit:2.0.2'
implementation 'com.basgeekball:awesome-validation:4.1'
implementation 'com.squareup.retrofit2:converter-gson:2.0.2'
implementation 'com.squareup.okhttp3:logging-interceptor:3.8.0'
}
注意:每个可绘制对象仅使用一次。
以下线程无法解决我的问题:
Drawable已经属于另一个所有者,但是没有公开恒定状态
找到的问题:以下属性导致了异常:
android:backgroundTint =“#000”
如果我不使用它,FAB上会有粉红色的背景:(
1> Ashutosh..:
固定:
在顶部布局中添加了xmlns:app =“ http://schemas.android.com/apk/res-auto”
使用了app:backgroundTint =“ @ color / colorFABTint”而不是android:backgroundTint =“#000”
在colors.xml中添加了以下行
#000000
结果xml: