以编程方式修改样式

发布于 2024-09-18 13:10:56 字数 229 浏览 3 评论 0原文

在我正在编写的 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

如果没有你 2024-09-25 13:10:56

不知道您是否已找到它,但 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文