2012-06-22 18 views
12

मैं Android Full Width ICS style Minimalist Bottom ButtonsViews में पूछने वाले लोगों की तरह दिखने के लिए स्टाइल बटन की कोशिश कर रहा हूं। हालांकिएंड्रॉइड शैलियाँ: 'शैली = "@ एंड्रॉइड के बीच अंतर: शैली/एक्सवाईजेड"' और 'शैली = "? एंड्रॉइड: एटीआर/एक्सवाईजेड"'?

<LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:layout_gravity="bottom" 
     android:divider="@android:drawable/divider_horizontal_dark" 
     android:gravity="bottom" 
     android:orientation="vertical" 
     android:paddingTop="16dip" 
     android:showDividers="beginning|end" > 

     <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:measureWithLargestChild="true" 
      android:orientation="horizontal" 
      android:divider="@android:drawable/divider_horizontal_dark" 
      android:showDividers="middle" >        


      <Button 
       android:id="@+id/cancel_button" 
       style="?android:attr/buttonBarButtonStyle" 
       android:layout_width="0dip" 
       android:layout_height="wrap_content" 
       android:layout_gravity="left" 
       android:layout_weight="1" 
       android:maxLines="2" 
       android:text="@string/cancel_button" /> 

      <Button 
       android:id="@+id/login_button" 
       style="?android:attr/buttonBarButtonStyle" 
       android:layout_width="0dip" 
       android:layout_height="wrap_content" 
       android:layout_gravity="right" 
       android:layout_weight="1" 
       android:filterTouchesWhenObscured="true" 
       android:maxLines="2" 
       android:text="@string/login_button" /> 

     </LinearLayout> 
    </LinearLayout> 

एक सवाल:

मुझे कोई दिलचस्पी किसी के लिए निम्नलिखित एक्सएमएल के साथ, सफल रहा है। ग्रहण सामग्री की सहायता पता नहीं क्या निम्न संसाधन संकल्प के साथ क्या हो रहा है है:

style="?android:attr/buttonBarButtonStyle"

मैं ठेठ संकल्प के साथ परिचित हूँ (जो ग्रहण की सामग्री की सहायता के बारे में पता है)

[email protected]/style/...

... लेकिन मैं दोनों के बीच के अंतर पर स्पष्ट नहीं हूँ। ऐसा लगता है कि कुछ स्टाइल गुण एक में दिखाई देते हैं लेकिन दूसरे नहीं। उदाहरण के लिए, निम्नलिखित कुछ भी करने के लिए हल नहीं होती है:

[email protected]:attr/buttonBarStyle

और न तो इस करता है:

  1. क्यों:

    style="@android:style/buttonBarStyle

    तो मैं यहाँ दो सवाल लगता है संसाधन संदर्भ वाक्यविन्यास में अंतर?

  2. क्यों एक एटीआर श्रेणी के तहत शैलियों का भ्रमित विचित्र वर्गीकरण।
  3. अटारी श्रेणी फिर से उपयोग की जाती है?

धन्यवाद!

उत्तर

13

another answer से इतने पर (यहाँ दूसरे शब्दों में बयान):

एक आईडी के सामने एक प्रश्न चिह्न उपयोग करने का अर्थ है कि आप एक शैली विशेषता कि बल्कि विशेषता हार्डकोड से, एक शैली विषय में परिभाषित किया गया है का उपयोग करना चाहते हैं।

इस बारे में सोचें कि संसाधन को लाने के लिए थीम विशेषता को संदर्भित करने के बजाय यह विशेषता को संदर्भित करने के बजाए इंगित करता है।

Referencing Style Attributes

1

एंड्रॉयड: attr/buttonBarButtonStyle या सिर्फ एंड्रॉयड? ButtonBarButtonStyle - (attr वैकल्पिक है)

<item name="buttonBarButtonStyle">@android:style/Widget.Button</item> 

यह आंतरिक रूप से @Android को dereferences: शैली/Widget.Button जिसे एपकोपेट/रेज/वैल्यू/themes.xml फ़ाइल के भीतर परिभाषित किया गया है।

(? एंड्रॉइड :) - हमेशा लागू-विषय से विशेषता के मूल्य से लिंक होता है। इस प्रकार हम एंड्रॉइड परिभाषित शैली को केवल एक नया बनाने और हार्ड-कोडित मूल्य की आपूर्ति करने की अनुमति देने की अनुमति देते हैं।

Google डॉक कहते हैं, "It uses the style that is defined by this attribute, in the current theme"

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