2011-03-17 7 views
18

काम करता है यह एक्सएमएल में नमूना टेक्स्ट व्यू है, जो पाठ दृश्य में TextContactContactName शैली को उचित रूप से लागू करेगा।टेक्स्टव्यू/एडिटटेक्स्ट पर "एंड्रॉइड: टेक्स्ट एपियरेंस" का उपयोग करना विफल रहता है, लेकिन "स्टाइल"

<TextView 
     android:id="@+id/name" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_toRightOf="@id/photo" 
     android:layout_alignTop="@id/photo" 
     android:paddingLeft="10dp" 
     android:text="First Last" 
     style="@style/TextContactContactName" 
     /> 

अब, मेरे पास इस तत्व पर सेट करने के लिए कुछ और चीजें हैं, जो टेक्स्ट से संबंधित नहीं हैं। ": TextAppearance एंड्रॉयड"

<TextView 
    android:id="@+id/name" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_toRightOf="@id/photo" 
    android:layout_alignTop="@id/photo" 
    android:paddingLeft="10dp" 
    android:text="First Last" 
    android:[email protected]/TextContactContactName" 
    /> 

दुर्भाग्य से, पाठ स्वरूपण लागू नहीं किया जा रहा है जैसे मैं TextContactContactName ले जाएँ और के माध्यम से इसे लागू करने की कोशिश।

इस तरह शैली (res/values/styles-text.xml में संग्रहीत) की तरह दिखता है:

<style name="TextContactContactName"> 
    <item name="android:textSize">24sp</item> 
    <item name="android:textColor">#333333</item> 
    <item name="android:shadowColor">#ffffff</item> 
    <item name="android:shadowDx">0</item> 
    <item name="android:shadowDy">1</item> 
    <item name="android:shadowRadius">1</item> 
</style> 

मैं textAppearance टैग गलत का उपयोग कर रहा हूं?

मैंने एंड्रॉइड 2.2 - एचटीसी डिजायर पर परीक्षण किया।

उत्तर

22

ठीक है, मेरी गलती की तरह दिखता है।

<TextView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="Text styled using 'style'." 
     style="@style/UiTestTextView" 
     /> 
<TextView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="Text styled using 'textAppearance'." 
     android:textAppearance="@style/UiTestTextView" 
     /> 

और शैलियों-text.xml:

<style name="UiTestTextView"> 
    <item name="android:textColor">#ff0000</item> 
    <item name="android:textSize">16sp</item> 

    <item name="android:shadowColor">#ffffff</item> 
    <item name="android:shadowDx">1</item> 
    <item name="android:shadowDy">2</item> 
    <item name="android:shadowRadius">3</item> 
</style> 

कुंजी बात को याद है कि shadow* तत्वों पाठ गुण नहीं हैं मैं एक त्वरित परीक्षण किया था। और जैसे टेक्स्ट एपियरेंस के माध्यम से लागू नहीं किया जाएगा।

मैं Android डेवलपर मेलिंग सूची पर पूछने के लिए यदि इस व्यवहार वांछित है जा रहा हूँ।

+3

आप डेवलपर्स से एक जवाब मिल गया है? मुझे यह भी जानकर खुशी होगी। – artemkaxboy

+0

यह स्पष्ट करने के लिए है कि यदि आप 'textAppearance' के माध्यम से लागू शैली में एक गैर-पाठ उपस्थिति विशेषता शामिल करते हैं तो पूरी शैली लागू होने में विफल हो जाती है? – AeroEchelon

1

मैंने इस मुद्दे पर एक बग रिपोर्ट दायर की। मुझे लगता है कि मुझे मानक जवाब मिला है "छाया को पाठ उपस्थिति का हिस्सा नहीं माना जाता है"।

http://code.google.com/p/android/issues/detail?can=2&start=0&num=100&q=&colspec=ID%20Type%20Status%20Owner%20Summary%20Stars&groupby=&sort=&id=35887

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