我的应用程序中有FloatingActionButton
。它在 Android N 和 O 中运行良好。但它在棉花糖中崩溃了。谁能帮我解决这个问题。
错误
Caused by: android.view.InflateException: Binary XML file line #0: Binary XML file line #0: Error inflating class android.support.design.widget.FloatingActionButton
at android.view.LayoutInflater.inflate(LayoutInflater.java:539)
at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
at LibraryFragment.onCreateView(LibraryFragment.java:69)
XML
<android.support.design.widget.FloatingActionButton
android:id="@+id/fabChat"
android:backgroundTint="#114358"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_marginBottom="100dp"
android:layout_marginRight="16dp"
app:srcCompat="@drawable/language"
app:borderWidth="0dp"
app:elevation="4sp" />
构建.gradle
compileSdkVersion 26
defaultConfig {
minSdkVersion 15
targetSdkVersion 26
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.mcxiaoke.volley:library:1.0.19'
compile 'com.github.moondroid.coverflow:library:1.0'
compile 'com.google.android.gms:play-services-ads:11.8.0'
compile 'com.android.support:recyclerview-v7:26.1.0'
compile 'com.android.support:cardview-v7:26.1.0'
compile 'com.android.support:design:26.1.0'
compile 'com.github.florent37:diagonallayout:1.0.2'
compile 'de.hdodenhof:circleimageview:2.1.0'
}
最佳答案
可能是因为您使用的 Android 设计库版本不同:
将其粘贴到依赖项中,如果它已经存在,则替换它
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:design:25.3.1'
同时将compileSdkVersion更改为25
同时更改:
android:backgroundTint="#114358"
与 app:backgroundTint="#114358"
如果您使用矢量资源作为 src,则使用
app:srcCompat="@drawable/you_graphics"
安装了这个
android:src="@drawable/your_graphics"
希望对你有帮助
关于android - float 操作按钮在棉花糖和 Lollipop 中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49291349/