2014-06-11 37 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