styles.xml 中 自定义的item报错提示Cannot resolve symbol ‘abc’

styles.xml 中 自定义的item报错提示Cannot resolve symbol
styles.xml 中 自定义的item报错提示Cannot resolve symbol ‘abc’
- 写回答
- 好问题 0 提建议
- 关注问题
- 邀请回答
-
2条回答 默认 最新
- 灯塔@kuaidao 2022-06-10 09:59关注
题主写的这种格式style只能匹配系统默认提供的属性。如果想自己取名字需要如下:
<resources> <!--系统提供. --> <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar"> <!-- Customize your theme here. --> <item name="colorPrimary">@color/colorPrimary</item> <item name="colorPrimaryDark">@color/colorPrimaryDark</item> <item name="colorAccent">@color/colorAccent</item> </style> <!--自定义--> <declare-styleable name="Custom"> <attr name="abc" format="boolean"></attr> <attr name="def" format="integer"></attr> </declare-styleable> </resources>
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 2无用