2014-06-11 42 views
1

我需要将主题应用于按钮,而不考虑应用程序主题(以编程方式或xml)。我发现已基本指着我的资源使用ContextThemeWrapper与这个问题是我无法找到正确的做的一个很好的例子将主题应用于单个视图

我的XML已经

<LinearLayout> 
<TextView> <!-- Should follow the current theme !> 
<Button> <!-- Needs to be irrespective of the theme; I need to put in the Light theme here always> 
</LinearLayout> 

我的onCreate我有

LayoutInflater to inflate 
getLayoutInflater().inflate .. 
TextVIew t = view.findViewById(txt); 
// How do I change this theme from code or XML 
Button b = view.findViewById(but); 

我需要应用一个主题;风格不会做。

感谢

回答

0

试试这个:

<Button 
    style="@style/MyStyle"> 

它应该是足够的。

+1

我不能这样做,风格基本上被我的应用程序主题覆盖。我有基于主题的多种风格 – user3547028