2012-04-18 18 views
14

एंड्रॉयड 1.6 या 2 में इस तरह सूचीदृश्य कैसे बनाएं (क्योंकि Renderscript है, जो केवल 3 में या बाद में काम करता है की, लेकिन मैं लगभग सभी एंड्रोइड्स पर काम करने की सूची की आवश्यकता):एंड्रॉयड: साथ कार्यक्षेत्र ListView ओवरलैप पंक्तियों

enter image description here

+0

कोई भी विचार कैसे है कि दृष्टिकोण के लिए? –

उत्तर

9

मैंने drawChild में Camera.setTranslate(x, 0, z) का उपयोग किया, जहां रोटेशन वर्चुअलाइजेशन और ज़ेड ओवरलैपिंग के लिए एक्स स्थिति बदल दी। फिर ओवरलैपिंग के साथ समस्या थी, क्योंकि आखिरी वस्तु शीर्ष पर थी और पहले नीचे परत पर थी। इसलिए, onCreate() विधि में this.setChildrenDrawingOrderEnabled(true) कहा जाता है और protected int getChildDrawingOrder (int childCount, int i) {} ओवरड्रिड होता है जहां मैं मध्य और बाद की पंक्तियों के लिए ऑर्डर बदल सकता हूं। यह विचार रेनार्ड द्वारा दिया गया था, जिन्होंने मुझे अन्य पोस्ट में लगभग here के बारे में सुझाव दिया था।

मेरे getChildDrawingOrder (int, int) कार्यान्वयन ओवरलैपिंग पाने के लिए मैं की जरूरत है:

@Override 
protected int getChildDrawingOrder (int childCount, int i) { 
    int centerChild = 0; 
    //find center row 
    if ((childCount % 2) == 0) { //even childCount number 
     centerChild = childCount/2; // if childCount 8 (actualy 0 - 7), then 4 and 4-1 = 3 is in centre.  
     int otherCenterChild = centerChild - 1; 
     //Which more in center? 
     View child = this.getChildAt(centerChild); 
     final int top = child.getTop(); 
     final int bottom = child.getBottom(); 
     //if this row goes through center then this 
     final int absParentCenterY = getTop() + getHeight()/2; 
     //Log.i("even", i + " from " + (childCount - 1) + ", while centerChild = " + centerChild); 
     if ((top < absParentCenterY) && (bottom > absParentCenterY)) { 
      //this child is in center line, so it is last 
      //centerChild is in center, no need to change 
     } else { 
      centerChild = otherCenterChild; 
     } 
    } 
    else {//not even - done 
     centerChild = childCount/2; 
     //Log.i("not even", i + " from " + (childCount - 1) + ", while centerChild = " + centerChild); 
    } 

    int rez = i; 
    //find drawIndex by centerChild 
    if (i > centerChild) { 
     //below center 
     rez = (childCount - 1) - i + centerChild; 
    } else if (i == centerChild) { 
     //center row 
     //draw it last 
     rez = childCount - 1; 
    } else { 
     //above center - draw as always 
     // i < centerChild 
     rez = i; 
    } 
    //Log.i("return", "" + rez); 
    return rez; 

} 

मुझे आशा है कि इस पोस्ट भविष्य

स्क्रीनशॉट में किसी को मदद मिलेगी वास्तव में लगभग एक ही है जैसा कि मैं अपने प्रश्न में आपका उल्लेख । मैं अल्फा इस्तेमाल किया है, तो आइटम ओवरले एक छोटा सा देखने के माध्यम से किया जाता है:

enter image description here

+0

@ पेंगवांग क्या डेमो? आपका मतलब परिणाम का स्क्रीनशॉट है? –

+0

हाँ, आप सही हैं, क्या आप परिणाम कोड – pengwang

+0

@PooLaS का अपना स्क्रीनशॉट साझा कर सकते हैं कृपया मुझे इस बात को समझने के लिए प्राथमिकता लिंक दें या अपनी कक्षाएं पोस्ट करें। –

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