2011-08-04 41 views
0

我不想做一件簡單的事情,我的背景的windowTitle必須改變我的應用程序。但是我怎樣才能訪問我的背景的windowTitle?只是一個簡單的事情關於windowsTitle改變Java背景

我style.xml:

<resources> 
<style name="CustomWindowTitleBackground"> 
    <item name="android:background">@drawable/fond</item> 
</style> 

<style name="CustomTheme" parent="android:Theme.Light"> 
    <item name="android:windowTitleSize">40dip</item> 
    <item name="android:windowTitleBackgroundStyle">@style/CustomWindowTitleBackground</item> 
</style> 
</resources> 

而且在我的活動:

super.onCreate(savedInstanceState); 
requestWindowFeature(Window.FEATURE_CUSTOM_TITLE); 
setContentView(R.layout.page_doc); 
getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.window_title); 

我可怎麼辦呢?

回答

0

您可以只使用WINDOW_TITLE佈局的ID。就像你會用普通的佈局一樣。 我假設你在window_title佈局中有類似LinearLayout的東西。只需使用它的ID來獲取它並設置Drawable背景。

+0

完美,謝謝:D – toshiro92

0

嘗試使用此

((TextView)((FrameLayout)((LinearLayout)((ViewGroup) activity.getWindow().getDecorView()).getChildAt(0)).getChildAt(0)).getChildAt(0)).setBackgroundResource(R.drawable.back); 
+0

我試過這個: RelativeLayout rl =(RelativeLayout)findViewById(R.id.relativeLayoutWindowTitle); rl.setBackgroundResource(R.drawable.fond_doc); – toshiro92