In my Android (API 30) app theme (file themes.xml) using MaterialComponents the "android:statusBarColor" works but displays the following error in red :Cannot resolve symbol 'android:statusBarColor'
You can reproduce this by creating a new android projet with the "Tabbed Activity" template :
<resources xmlns:tools="http://schemas.android.com/tools">
<!-- Base application theme. -->
<style name="Theme.AppTest" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
<!-- Primary brand color. -->
<item name="colorPrimary">@color/purple_500</item>
<item name="colorPrimaryVariant">@color/purple_700</item>
<item name="colorOnPrimary">@color/white</item>
<!-- Secondary brand color. -->
<item name="colorSecondary">@color/teal_200</item>
<item name="colorSecondaryVariant">@color/teal_700</item>
<item name="colorOnSecondary">@color/black</item>
<!-- Status bar color. IN RED - "Cannot resolve symbol" below -->
<item name="android:statusBarColor" tools:targetApi="l">?attr/colorPrimaryVariant</item>
<!-- Customize your theme here. -->
</style>
In fact, all android items in themes produce this Cannot resolve symbol, like :
<style name="ToolbarPopupTheme" parent="ThemeOverlay.MaterialComponents">
<!-- android:background below in RED-->
<item name="android:background">?attr/colorPrimary</item>
</style>
If any of you have any insight on this, it would be great.
question from:
https://stackoverflow.com/questions/65858339/android-theme-cannot-resolve-symbol-error-on-statusbarcolor-item 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…