apsingToolbarLayout上设置contentcri

apsingToolbarLayout上设置contentcri

本文介绍了在CollapsingToolbarLayout上设置contentcrim颜色时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序最近开始在具有CollapsingToolbarLayout且具有以下错误日志的任何活动或片段上崩溃:

My app recently started to crash on any activity or fragment that has a CollapsingToolbarLayout with the following error log:

`

Unable to start activity ComponentInfo{com.radioafrica.music/com.radioafrica.music.activity.PlaylistTracks}: android.view.InflateException: Binary XML file line #31: Binary XML file line #31: Error inflating class android.support.design.widget.CollapsingToolbarLayout
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2416)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
at android.app.ActivityThread.-wrap11(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Caused by: java.lang.NoSuchMethodError: No static method setLayoutDirection(Landroid/graphics/drawable/Drawable;I)V in class Landroid/support/v4/graphics/drawable/DrawableCompat; or its super classes (declaration of 'android.support.v4.graphics.drawable.DrawableCompat' appears in /data/data/com.radioafrica.music/files/instant-run/dex/slice-com.android.support-support-v4-24.0.0-beta1_f8cf3ba4c70f87f407a745b9fa14a2205d0b587c-classes.dex)
at android.support.design.widget.CollapsingToolbarLayout.setStatusBarScrim(CollapsingToolbarLayout.java:663)
at android.support.design.widget

`

当我注释掉collapsingToolbarLayout.setStatusBarScrim(color);时,它可以正常工作,但缺点是我无法设置稀松布颜色,并且标题未显示在工具栏上.这是支持库的错误吗?

When i comment out collapsingToolbarLayout.setStatusBarScrim(color); , it works fine, but the downside is that i cant set a scrim color and the title doesnt show on the toolbar. Is this a bug with the support library?

推荐答案

我设法通过遍历build.gradle文件并删除了可能具有v4 support library其他版本的任何依赖项,从而消除了该错误.似乎是库的版本冲突是问题所在.

I managed to get rid of the error by going through my build.gradle file and removing any dependency that might have another version of the v4 support library. It seems that the conflicting versions of the libraries were the problem.

这篇关于在CollapsingToolbarLayout上设置contentcrim颜色时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-18 18:44