2013-10-05 5 views
14

क्या शोकेस व्यू में शीर्षक और संदेश की स्थिति सेट करने का कोई तरीका है? मुझे लगता है कि पुस्तकालय सबसे अच्छी स्थिति खोजने के लिए एक फ़ंक्शन का उपयोग करता है लेकिन मैं इसे ओवरराइड करना चाहता हूं।शोकेस देखें टेक्स्ट गुरुत्वाकर्षण

+1

कृपया बताएं कि आप क्या कहने की कोशिश कर रहे हैं, अपना कोड दिखाएं और फिर आपको जो समस्या मिल रही है उसे समझाएं। –

+0

अद्यतन ओप। अभी भी ऐसा करने का कोई तरीका नहीं मिला है। – arayray

+0

शोकेस व्यू जिथब पर सबमिट की गई समस्या। https://github.com/Espiandev/ShowcaseView/issues/113 – arayray

उत्तर

8

मैंने अभी ShowcaseView स्रोत कोड में खोला है और ऐसा लगता है कि टेक्स्ट स्थिति सेट करने के लिए कोई रास्ता नहीं बनाया गया है। तो मैंने पुस्तकालय में अपना स्वयं का संशोधन जोड़ा।

वर्ग ShowcaseView में इन क्षेत्रों कहा::

private boolean hasManualPostion = false; 
private int xPosition, yPosition, width; 
फिर Builder वर्ग जो ShowcaseView कक्षा में भीतरी वर्ग है में

, इन तरीकों जोड़ें:

 public Builder hasManualPosition(boolean hasManualPosition) { 
     showcaseView.hasManualPostion = hasManualPosition; 
     return this; 
    } 

    public Builder xPostion(int xPostion) { 
     showcaseView.xPosition = xPostion; 
     return this; 
    } 

    public Builder yPostion(int yPostion) { 
     showcaseView.yPosition = yPostion; 
     return this; 
    } 
यहाँ परिवर्तन है कि मैं बना दिया है

उसके बाद, इस विधि को TextDrawer वर्ग में जोड़ें:

public void setTestPostionManually(int xPosition, int yPosition) { 
    mBestTextPosition[0] = xPosition; 
    mBestTextPosition[1] = yPosition; 
} 

और ShowcaseView में अंत परिवर्तन onPreDraw विधि में इस तरह देखने के लिए:

@Override 
public boolean onPreDraw() { 
    boolean recalculatedCling = showcaseAreaCalculator.calculateShowcaseRect(showcaseX, showcaseY, showcaseDrawer); 
    boolean recalculateText = recalculatedCling || hasAlteredText; 
    if (recalculateText) { 
     textDrawer.calculateTextPosition(getMeasuredWidth(), getMeasuredHeight(), this, shouldCentreText); 
     if (hasManualPostion) { 
      textDrawer.setTestPostionManually(xPosition, yPosition); 
     } 
    } 
    hasAlteredText = false; 
    return true; 
} 

अब आप ShowcaseView इस तरह बनाना चाहिए:

sv = new ShowcaseView.Builder(this, true) 
       .setTarget(target) 
       .setContentTitle(R.string.showcase_main_title) 
       .setContentText(R.string.showcase_main_message) 
       .setStyle(R.style.CustomShowcaseTheme2) 
       .setShowcaseEventListener(this) 
       .hasManualPosition(true) 
       .xPostion(0) 
       .yPostion(240) 
       .build(); 

का आनंद लें!

+0

यह संस्करण कौन सा है? किसी भी विचार को विरासत में कैसे काम करना है? –

+1

संशोधन 5.0.0 – Sadegh

+0

के लिए है क्या आप 5.0.0 में हाथ एनीमेशन लाने के किसी भी तरीके से जानते हैं? –

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