2010-09-03 14 views
5

मैं एक नौसिखिया Android के लिए development.Now मैं परिपत्र की तरह छवि के रूप में गैलरी दृश्य करना चाहते हैं कर रहा हूँ के रूप में below.The चीजें हैं जो मैं केंद्र छवि विस्तार करने के लिए जब उपयोगकर्ता स्क्रॉल से दाएं और बाएं के लिए बाएं चाहते हैं। क्या इसके लिए कोई ट्यूटोरियल है?एंड्रॉइड सर्कुलर गैलरी?

enter image description here क्या मैं चाहता हूँ यह केंद्र में है, जबकि छवि है कि जरूरत स्वाइप कर रहा है बढ़े हुए किया जा रहा है। मैंने सोचा कि मैं इसे गैलरी के साथ कर सकता हूं। लेकिन एंड्रॉइड डेवलपर का उदाहरण वह नहीं है जिसे मैं चाहता हूं। :(

उत्तर

5


आप केंद्र चयनित छवि विस्तार करने के लिए चाहते हैं, तो आपकी onItemSelected विधि पर एक संभव तरीका है , बस वस्तु ज़ूम करने के लिए एक एनीमेशन फोन संपत्ति गैलरी की है कि वह हमेशा केंद्र बंद कर दिया। तो केंद्र तत्व हमेशा चयन किया जाएगा। आशा है कि काम करेगा है ..

<?xml version="1.0" encoding="utf-8"?> 
<set 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:shareInterpolator="false" 
    android:fillAfter="true" 
> 
<scale 
     android:fromXScale="1.0" 
     android:toXScale="1.50" 
     android:fromYScale="1.0" 
     android:toYScale="1.50" 
     android:duration="600" 
     android:pivotX="50%" 
     android:pivotY="50%" 
     android:fillAfter="true"/> 

</set> 

याद है कि आप STO करना होगा पिछले दृश्य को फिर से करें जब तत्व केंद्र से दूर हो जाता है, इसे सामान्य आकार में रखा जाना चाहिए। prevView और currView -

तो तुम दो बार देखा गया हो सकता है।
currView पर एनीमेशन करो।

धन्यवाद,
सेन

12

youcan कोशिश:।।

public class TestGallery extends Activity { 
/** Called when the activity is first created. */ 
private Integer[] mImageIds = { R.drawable.sample_1, R.drawable.sample_2, R.drawable.sample_3, R.drawable.sample_4 }; 

@Override 
public void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.main); 

    Gallery g = (Gallery) findViewById(R.id.gallery); 
    g.setAdapter(new ImageAdapter(this)); 

    g.setOnItemClickListener(new OnItemClickListener() { 
     public void onItemClick(AdapterView parent, View v, int position, long id) { 
      if (position >= mImageIds.length) { 
       position = position % mImageIds.length; 
      } 
      Toast.makeText(TestGallery.this, "" + position, Toast.LENGTH_SHORT).show(); 
     } 
    }); 

} 

public class ImageAdapter extends BaseAdapter { 
    int mGalleryItemBackground; 
    private Context mContext; 

    public ImageAdapter(Context c) { 
     mContext = c; 
     TypedArray a = obtainStyledAttributes(R.styleable.Gallery1); 
     mGalleryItemBackground = a.getResourceId(R.styleable.Gallery1_android_galleryItemBackground, 0); 

     a.recycle(); 
    } 

    public int getCount() { 
     return Integer.MAX_VALUE; 
    } 

    public Object getItem(int position) { 
     if (position >= mImageIds.length) { 
      position = position % mImageIds.length; 
     } 
     return position; 
    } 

    public long getItemId(int position) { 
     if (position >= mImageIds.length) { 
      position = position % mImageIds.length; 
     } 
     return position; 
    } 

    public View getView(int position, View convertView, ViewGroup parent) { 
     ImageView i = new ImageView(mContext); 
     if (position >= mImageIds.length) { 
      position = position % mImageIds.length; 
     } 
     i.setImageResource(mImageIds[position]); 
     i.setLayoutParams(new Gallery.LayoutParams(80, 80)); 
     i.setScaleType(ImageView.ScaleType.FIT_XY); 
     i.setBackgroundResource(mGalleryItemBackground); 
     return i; 
    } 

    public int checkPosition(int position) { 
     if (position >= mImageIds.length) { 
      position = position % mImageIds.length; 
     } 
     return position; 
    } 
}} 
+0

हाय PengWang सूचीबद्ध में इस के दोनों लागू किया, मैं पहले से ही अपने कोड की कोशिश की और यह कुछ भी नहीं बदलता है। कोई विचार ? – geekmyo

+0

पेंगवांग का कोड * अनुकरण * –

+0

+1 विस्तार से अनंत लूपिंग समाधान के लिए धन्यवाद .. !! –

1

मैं इसके लिए अपने खुद के ट्यूटोरियल बनाया: http://evgeni-shafran.blogspot.com/2011/08/tutorial-custom-gallery-circular-and.html

यह परिपत्र आप इसे लगता है कि यह बहुत से आइटम, एक बहुत अधिक तो है बनाने की जरूरत है बनाने के लिए आप वास्तव में है।

और फिर स्थिति बनाकर = स्थिति% items.length आप की तरह कुछ (मैं 3 मदों के लिए यह दिखाई देगा) बनाने के लिए: 1,2,3,1,2,3,1,2,3,1,2 , 3,1,2,3,1,2,3,1,2,3 और फिर बीच में जाना तो भले ही पुस्तक एक बहुत वह अभ्यस्त के पास समाप्त करने के लिए आते हैं। 1,2,3,1,2,3,1,2,3, -> < - 2,3,1,2,3,1,2,3,1,2,3

इसे चुनने के लिए: आपको setOnItemSelectedListener को ओवरराइड करने और आकार में हेरफेर करने की आवश्यकता है। न आपके पिछली बार देखने के लिए एक संदर्भ को बचाने के लिए ताकि आप इसे नियमित रूप से देख सकते हैं जब आप अगली बार एक के लिए मिलता है भूल जाते हैं, बढ़े नहीं।

मैं अपने ट्यूटोरियल ऊपर

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