Android ContextWrapper覆盖ContextThemeWrapper?
我有一个与上下文相关的令人困惑的情况 我正在实现crowdin,这个sdk在运行时覆盖Android ContextWrapper覆盖ContextThemeWrapper?,android,android-theme,android-context,material-components-android,crowdin,Android,Android Theme,Android Context,Material Components Android,Crowdin,我有一个与上下文相关的令人困惑的情况 我正在实现crowdin,这个sdk在运行时覆盖string.xml上下文 Crowdin.wrap(context) //ContextWrapper() 当不包装上下文时效果很好,但是当尝试使用materialalertialogbuilder将上下文包装为crowdin时,应用程序崩溃,出现下一个异常 android.view.InflateException: Binary XML file line #25 in com.example.app_
string.xml
上下文
Crowdin.wrap(context) //ContextWrapper()
当不包装上下文时效果很好,但是当尝试使用materialalertialogbuilder
将上下文包装为crowdin时,应用程序崩溃,出现下一个异常
android.view.InflateException: Binary XML file line #25 in com.example.app_user.user:layout/mtrl_alert_dialog: Binary XML file line #27: You must supply a layout_width attribute.
Caused by: java.lang.UnsupportedOperationException: Binary XML file line #27: You must supply a layout_width attribute.
未找到布局\u宽度
属性的文件来自材料组件
我认为这个错误可能是因为材料首先应用了ContextThemeWrapper
,然后crowdin在上下文包装(ContextThemeWrapper)上应用了
- Appcompat:1.2.0
- 材料:1.1.0
@NonNull
@凌驾
公共AppCompatDelegate getDelegate(){
返回新的BaseContextWrappingDelegate(super.getDelegate());
}
重点补充
您向我们展示的代码似乎是AppCompat 1.1使用的方法
此外,我在类层次结构中没有看到BaseActivity
。因此,您需要确保每个活动
都包含上述代码,或者创建一个包含该代码的基本活动
,并确保所有其他活动
扩展它
如果这些都不起作用,您需要提供有关覆盖上下文的位置的信息,并向我们展示其中的代码:
- 在
或应用程序
类中的活动
attachBaseContext
- 在
getDelegate