应用主题到appwidget [英] applying a theme to an appwidget

查看:160
本文介绍了应用主题到appwidget的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图定义一个主题为appwidget,并将它应用在 应用层。我有一个类似的主题,

i'm trying to define a theme for an appwidget, and have it applied at the application level. i have a theme like,

<style name="theme.dark"> 
  <item name="android"background">#000000</item> 
</style> 

在我的清单,我设置安卓主题=@风格/ theme.dark在应用程序。然而,当我运行appwidget,它不会拿起从样式的项目。我试着设置风格=@风格/ theme.dark在我看来,布局一个单独的元素,而没有工作......但是这不是我想要的。我不想调出特定样式=...在我看来,每一个元素。这个页面,

in my manifest, i set android:theme="@style/theme.dark" at the application. however, when i run the appwidget, it does not pick up the items from the style. i tried setting style="@style/theme.dark" on an individual element in my view layout, and that does work ... but that's not what i want. i don't want to call out a specific style="..." for each element in my view. this page,

http://www.androidengineer.com/ 2010/06 /使用主题功能于Android的applications.html

有使用主题/风格一个很好的例子应用程序,它完美的作品。唯一的区别是,它是一个应用程序..和它的设置主题上的活动,而不是应用程序。

has an excellent example app for using themes / styles, and it works perfectly. the only difference is that it's an application .. and it's setting the theme on the activity, not the application.

我也试着设置主题在编程方式使用appwidget的setTheme(...)的onHandleUpdate()的上下文对象,该视图访问之前。那也不行。

i've also tried setting the theme at programmatically on the Context object using setTheme(...) in onHandleUpdate() of the appwidget, before the view is accessed. that doesn't work either.

什么想法? 谢谢。

推荐答案

答案是,你不能动态地应用主题到appwidget。有没有解决方案,除了提供多种布局的每个静态引用一个特定的主题,然后采摘,当你建立自己的远程视图正确的主题/布局等。

the answer is that you can't apply a theme dynamically to an appwidget. there's no solution other than providing multiple layouts each statically referencing a particular theme, then picking the correct theme/layout when you build your remote views.

这篇关于应用主题到appwidget的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆