概述
从深色模式切换到浅色模式报错
java.lang.IllegalArgumentException:
Wrong state class, expecting View State
but received class com.google.android.material.button.MaterialButton$SavedState instead.
This usually happens when two views of different type
have the same id in the same hierarchy
--------------------2021年11月26日00:15:04--------------------
问题在于 values/themes.xml
里面有两个两个themes.xml 一个是深色模式用的,一个是浅色用的, 里面的 style 标签的style属性要一样
我原来是下面的,后来把后面的bridge删掉就好了
parent="Theme.MaterialComponents.DayNight.DarkActionBar.Bridge"
parent="Theme.MaterialComponents.DayNight.DarkActionBar"
----------------------------分割线-----------------------------------
我之前的解决方式是xml中不使用默认的Button, 而是使用compactButton 这个方式是避开了这个问题, 但是仍然未解决这个问题
最后
以上就是等待大米为你收集整理的android 从深色模式切换到浅色模式报错 java.lang.IllegalArgumentException: Wrong state class, expecting View State的全部内容,希望文章能够帮你解决android 从深色模式切换到浅色模式报错 java.lang.IllegalArgumentException: Wrong state class, expecting View State所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复