2012-06-30 15 views
14

ठीक है, फिर भी मैं और अधिक स्वच्छता खो रहा हूं। मैं नहीं जानता/समझ सकता हूं कि कैसे खराब चीज को स्टाइल करना है। मैं टैब की पृष्ठभूमि को बदलने में कामयाब रहा लेकिन मैं चयनित टैब के नीचे बार के रंग को नहीं जोड़ सकता।actionbarsherlock में टैब 'अंडरबार' का रंग कैसे बदलें

इसे नीले रंग से कुछ में कैसे बदला जाए। जहां मैं क्या गुण (पृष्ठभूमि) की तरह कुछ सामान है पा सकते हैं:

मेरे styles.xml दुर्भाग्य से मैं यह कैसे काम करता

<?xml version="1.0" encoding="utf-8"?> 
<resources> 


    <style name="Theme.Styled" parent="Theme.Sherlock.Light"> 
     <item name="actionBarTabStyle">@style/Widget.Styled.ActionBarTab</item> 
     <item name="android:actionBarTabStyle">@style/Widget.Styled.ActionBarTab</item> 

     <item name="actionBarTabBarStyle">@style/Widget.Styled.ActionBarTabBar</item> 
     <item name="android:actionBarTabBarStyle">@style/Widget.Styled.ActionBarTabBar</item> 

     <item name="actionBarTabTextStyle">@style/myText</item> 
     <item name="android:actionBarTabTextStyle">@style/myText</item> 


    </style> 

    <style name="Widget.Styled.ActionBarTab" parent="Widget.Sherlock.Light.ActionBar.TabView"> 
    <!-- <item name="background">@drawable/startbcg</item> 
     <item name="android:background">@drawable/startbcg</item> 
     <item name="backgroundSplit">@drawable/bg_striped_split</item> 
     <item name="android:backgroundSplit">@drawable/bg_striped_split</item> 
    --> 
    </style> 


    <style name="Widget.Styled.ActionBarTabBar" parent="Widget.Sherlock.Light.ActionBar.TabBar"> 

     <item name="background">@drawable/startbcg</item> 
     <item name="android:background">@drawable/startbcg</item> 
     <item name="backgroundSplit">@drawable/bg_striped_split</item> 
     <item name="android:backgroundSplit">@drawable/bg_striped_split</item> 

    </style> 

    <style name="myText" parent="Widget.Sherlock.Light.ActionBar.TabText"> 
     <item name="android:textAppearance">@android:style/TextAppearance.Medium</item> 
     <item name="android:textColor">@android:color/primary_text_dark</item> 
     <item name="android:textSize">10sp</item> 


    </style> 
<style name="myTextInv" parent="Widget.Sherlock.Light.ActionBar.TabText.Inverse"> 
     <item name="android:textAppearance">@android:style/TextAppearance.Medium</item> 
     <item name="android:textColor">@android:color/primary_text_dark</item> 
     <item name="android:textSize">10sp</item> 


    </style> 
</resources> 

बोनस सवाल का बहुत बुरा समझ है।

उत्तर

8

मैंने पाया कि पृष्ठभूमि के लिए एंड्रॉइड एसडीके res निर्देशिका पर पाए गए ड्रॉबल्स (9 पैच और एक्सएमएल) की प्रतिलिपि बनाना बेहतर है और इसे पसंद करने वाला रंग बदलने के लिए बेहतर है।

वे नीचे की बार के साथ पृष्ठभूमि का उपयोग करते हैं, इसलिए मुझे नहीं लगता कि अकेले नीचे बार को बदलना संभव है।

यहाँ है कि मैं क्या है, नीचे पट्टी के लिए हरे रंग के साथ काम कर रहा है:

<style name="customTabStyle" parent="Widget.Sherlock.ActionBar.TabView"> 
    <item name="android:showDividers">none</item> 
    <item name="android:measureWithLargestChild">true</item> 
    <!-- This was a copy from the sdk drawable --> 
    <item name="android:background">@drawable/tab_indicator</item> 

    <item name="background">@drawable/tab_indicator</item> 
    <item name="android:gravity">center</item> 
    <item name="android:textStyle">normal</item> 
</style> 


<style name="customTabBar" parent="Widget.Sherlock.ActionBar.TabBar"> 
    <item name="android:showDividers">middle</item> 

    <item name="android:divider">@drawable/tab_divider</item> 
    <item name="divider">@drawable/tab_divider</item> 

    <item name="android:dividerPadding">10dip</item> 

    <item name="android:background">@drawable/tab_bg</item> 
</style> 

टैब सूचक इस तरह दिखता है:

<?xml version="1.0" encoding="utf-8"?> 
<selector xmlns:android="http://schemas.android.com/apk/res/android"> 
<!-- Non focused states --> 
<item android:state_focused="false" android:state_selected="false" android:state_pressed="false" android:drawable="@drawable/tab_unselected" /> 
<item android:state_focused="false" android:state_selected="true" android:state_pressed="false" android:drawable="@drawable/tab_selected" /> 

<!-- Focused states --> 
<item android:state_focused="true" android:state_selected="false" android:state_pressed="false" android:drawable="@drawable/tab_unselected_focused" /> 
<item android:state_focused="true" android:state_selected="true" android:state_pressed="false" android:drawable="@drawable/tab_selected_focused" /> 

<!-- Pressed --> 
<!-- Non focused states --> 
<item android:state_focused="false" android:state_selected="false" android:state_pressed="true" android:drawable="@drawable/tab_unselected_pressed" /> 
<item android:state_focused="false" android:state_selected="true" android:state_pressed="true" android:drawable="@drawable/tab_selected_pressed" /> 

<!-- Focused states --> 
<item android:state_focused="true" android:state_selected="false" android:state_pressed="true" android:drawable="@drawable/tab_unselected_pressed" /> 
<item android:state_focused="true" android:state_selected="true" android:state_pressed="true" android:drawable="@drawable/tab_selected_pressed" /> 
</selector> 

मुझे आशा है कि यह मदद करता है!

+0

मैं यहां कुछ ऐसा कर रहा हूं !!! http://stackoverflow.com/questions/19623805/actionbarsherlock-stacked-action-bar-styling-issue – toobsco42

17

एक्शनबार शैली के लिए ActionbarStyleGenerator का उपयोग करें। यह अब तक का सबसे सरल और सबसे सहज तरीका है।

कैसे करें:

  1. अलग
  2. मदों के लिए रंग का चयन करने के यूआई का उपयोग करें पर "डाउनलोड .ZIP"
  3. क्लिक ऐसा करने के बाद
  4. ज़िप फ़ाइल आप में नकल करने के लिए है कि संसाधन फ़ाइलें हैं अपने प्रोजेक्ट रेस/लेआउट और res/drawableXXXX फ़ोल्डर्स
+0

आवश्यक फ़ाइलों को डाउनलोड और कॉपी करने के बाद मुझे कोड में कुछ भी बदलने की ज़रूरत है? – Shrikant

+1

@Shrikant, आप अपने मैनिफ़ेस्ट फ़ाइल में गतिविधि के लिए विषय आवंटित करने के लिए की जरूरत है: <गतिविधि ... एंड्रॉयड: विषय = "@ शैली/Theme.Example"> –

+0

मैं इसे करने की कोशिश की, लेकिन अभी भी करने में सक्षम नहीं वांछित परिणाम प्राप्त करें :( – Shrikant

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