2011-07-05 16 views

उत्तर

4

View titleView = getWindow().findViewById(android.R.id.titlebar); 
    if (titleView != null) { 
     ViewParent parent = titleView.getParent(); 
     if (parent != null && (parent instanceof View)) { 
     View parentView = (View)parent; 
     parentView.setBackgroundColor(Color.RED); 
     } 
    } 
+3

android.R.id.titlebar जहां मैंने इसे पाया या जहां मैं इसे बना रहा हूं ??? – Friz14

+0

tkns मुझे यह मिला ":) – Friz14

+1

@ Friz14 आपको यह कहां मिला? मैं [एक समान समस्या] में भाग गया (http://stackoverflow.com/q/11263829/869501) और मुझे वह 'android.R.id.titlebar' नहीं मिल रहा है। धन्यवाद +1। – ateiob

-1

मुझे लगता है कि यह अन्य dicussion आपके लिए उपयोगी हो जाएगा:

Set title background color

+0

उन्होंने विशेष रूप से ** बिना थीम के ** पूछा। – ateiob

0

ActionBar बार = getActionBar() निम्न कोड के साथ प्रयास करें; bar.setBackgroundDrawable (नया रंग निकालने योग्य (getResources()। Getcolor (R.color.material_blue_gray1)));

+0

यदि आप android.support.v7.app.ActionBar का उपयोग करते हैं तो getActionBar के स्थान पर getSupportActionBar() का उपयोग करें –

संबंधित मुद्दे