Bry*_*yan 25 android syntax-error android-context android-lint android-support-library
我开始使用a ContextThemeWrapper
来动态地应用一个样式ImageButton
; 基于对我的另一个问题的回答,以及对其他类似 问题的回答.
ContextThemeWrapper wrapper = new ContextThemeWrapper(getContext(), mStyleRes);
mImageButton = new AppCompatImageButton(wrapper, null, 0);
Run Code Online (Sandbox Code Playgroud)
但最近一个lint错误开始出现在ContextThemeWrapper
构造函数上:
ContextThemeWrapper
只能从同一个库组中调用(groupId = com.android.support)
我注意到标有@RestrictTo(LIBRARY_GROUP)
注释的类,这会导致lint错误出现.但是我找不到任何关于它为什么仅限于com.android.support
图书馆组的信息.
据我所知,这是以View
编程方式应用样式,主题或主题叠加的唯一方法; 除了将默认样式属性设置为构造函数中的第三个参数之外.所以我想知道为什么它的使用会受到限制; 在支持库之外使用类有什么问题吗?可能会有我不知道的副作用吗?
我遇到的唯一类似的问题是关于(现在已修复)的错误; 导致此lint错误显示在onCreate
子类的方法上AppCompatActivity
.我认为这不是一个错误,而是一个故意的限制; 我想知道背后的推理.
我应该注意; 这个限制(截至目前)实际上似乎对使用a的代码没有影响ContextThemeWrapper
.它编译并运行良好,并按照我的预期工作.
eph*_*ent 57
android.view.ContextThemeWrapper
!= android.support.v7.view.ContextThemeWrapper
.
支持库一个是注释的@RestrictTo(LIBRARY_GROUP)
,而且@hide
- 它不是一个公共API.
第一个是公开的.
归档时间: |
|
查看次数: |
7338 次 |
最近记录: |