使用API​​ <21 NavigationView.setBackgroundTintList

时间:2019-01-25 15:01:51

标签: android android-support-library

我的项目遇到严重问题,它正在影响使用android <21的多个用户。 我更改了navigationView的颜色,但是当使用android <21时,应用程序将引发异常。 较大的版本可以正常工作。

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
{
navigationView.setBackgroundTintList(ColorStateList.valueOf(ContextCompat.getColor(context, ThemeUtil.getThemeList().get(mTheme).getPrimaryColor())));
}else {
((TintableBackgroundView)navigationView).setSupportBackgroundTintList(ColorStateList.valueOf(tintColor));
}

问题在这一行:

((TintableBackgroundView) navigationView) .setSupportBackgroundTintList (ColorStateList.valueOf (tintColor));

如何在NavigationView中使用setSupportBackgroundTintList?

0 个答案:

没有答案