我是靠谱客的博主 等待大米,最近开发中收集的这篇文章主要介绍android 从深色模式切换到浅色模式报错 java.lang.IllegalArgumentException: Wrong state class, expecting View State,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

从深色模式切换到浅色模式报错

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所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(46)

评论列表共有 0 条评论

立即
投稿
返回
顶部