最近集成chromcast 到项目里,总是在不停的报错,后来发现我theme用的不对,要得用
Theme.AppCompat 下面的theme, 之前我的activity 用的是 @android:style/Theme.NoTitleBar,
我也看了源码,这估计是因为inflate在加载xml的时候,用不同的theme来画view,然后不同的theme 有不同的写法
正确的theme
<style name="AppThemeCast"
parent="Theme.AppCompat.NoActionBar">
<!-- Set AppCompat’s color theming attrs -->
<item name="colorPrimary">@color/white</item>
<item name="colorPrimaryDark">@color/black</item>
<item name="colorAccent">@color/gray</item>
<item name="android:textColorPrimary">@color/white</item>
<item name="android:textColorSecondary">@color/black</item>
<item name="windowNoTitle">true</item>
<!-- The rest of your attributes -->
<!--item name="android:seekBarStyle">@style/YellowSeekBar</item-->
</style>
Caused by: java.lang.IllegalArgumentException: background can not be translucent: #0
at android.support.v4.graphics.ColorUtils.calculateContrast(ColorUtils.java:92)
at android.support.v7.app.MediaRouterThemeHelper.getControllerColor(MediaRouterThemeHelper.java:75)
at android.support.v7.app.MediaRouterThemeHelper.createThemedContext(MediaRouterThemeHelper.java:53)
at android.support.v7.app.MediaRouteButton.<init>(MediaRouteButton.java:123)
at android.support.v7.app.MediaRouteButton.<init>(MediaRouteButton.java:119)
https://code.google.com/p/android/issues/detail?can=2&start=0&num=100&q=&colspec=ID%20Status%20Priority%20Owner%20Summary%20Stars%20Reporter%20Opened&groupby=&sort=&id=192960