以编程方式修改样式
在我正在编写的 Android 应用程序中,各种 TextView
元素的样式是在 xml 资源中定义的。我希望用户能够使用 PreferenceActivity
更改某些样式,例如 android:typeface
。
有没有办法以编程方式修改样式资源,以便所有关联的小部件都能正确更新?如果不是,我必须通过 id 手动选择所有小部件并更改其样式吗?
In an Android application I am writing, the styling for my various TextView
elements is defined in an xml resource. I would like enable the user to change certain styles such as android:typeface
using a PreferenceActivity
.
Is there a way to modify a style resource programmatically such that all associated widgets will update correctly? If not, must I manually select all widgets by id and change their styling?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不知道您是否已找到它,但 Cubewallpaper 示例使用首选项,并且似乎在 onSharedPreferenceChanged 事件中手动完成所有操作。
您可以将首选项键保留在资源文件中,但它会显示的仅此而已。
Don't know whether you've found it but the Cubewallpaper sample uses preferences and that appears to do it all by hand in the onSharedPreferenceChanged event.
You can keep the preference keys in a resource file but that's about it it would appear.