Note that there are some explanatory texts on larger screens.

plurals
  1. POMake carousel with ViewFlipper or ViewPager
    primarykey
    data
    text
    <p>Since <code>GalleryView</code> deprecated we should immigrate to some alternative widgets, In my case <code>ViewFlipper</code> is the best but I have faced with several issues, as you can see in the following screenshot I have designed a carousel <code>ImageGallery</code> with <code>GalleryView</code>:</p> <p><img src="https://i.stack.imgur.com/DTdXp.png" alt="enter image description here"></p> <p>With <code>ViewFlipper</code> everything works as I expected, But I'm not able to implement two things:</p> <p><strong><em>1- <code>ViewFlipper</code> always shows one item; however I need to display three items (or even more) at once.</em></strong></p> <p><strong><em>2- <code>ViewFlipper</code> is non-touchable widget and it's not what I want!</em></strong></p> <hr> <p><strong>As FlávioFaria mentioned about <code>ViewPager</code> in the following post, It's a great case too but I can't pass my scale up animation to it!</strong></p> <p><strong>I've done everything with <code>ViewPager</code>, now it's working great but I have missed one functionality and that is infinity scrolling!</strong></p> <p><strong>Added my <code>PagerAdapter</code> class</strong></p> <pre><code>public class CarouselAdapter extends PagerAdapter { private Context mContext; private ImageLoader imageLoader; private String[] bannerUri; public CarouselAdapter (Context c, String[] bannerArray) { this.mContext = c; this.bannerUri = bannerArray; // Setup image loader this.imageLoader = ImageLoader.getInstance(); ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(c) .threadPoolSize(2) .memoryCache(new WeakMemoryCache()) .discCacheFileNameGenerator(new Md5FileNameGenerator()) .build(); this.imageLoader.init(config); } @Override public Object instantiateItem(ViewGroup container, int position) { if (position &gt;= bannerUri.length) position %= bannerUri.length; ImageView i = new ImageView(mContext); displayImage(i, bannerUri[position]); i.setScaleType(ScaleType.FIT_XY); container.addView(i); return i; } @Override public void destroyItem(ViewGroup container, int position, Object object) { container.removeView((View)object); } @Override public int getCount() { return Integer.MAX_VALUE; } @Override public boolean isViewFromObject(View view, Object object) { return (view == object); } private void displayImage(final ImageView mImage, String ImageUri) { DisplayImageOptions defaultOptions = new DisplayImageOptions.Builder() .showStubImage(R.drawable.border) .showImageForEmptyUri(R.drawable.border) .imageScaleType(ImageScaleType.EXACTLY) .bitmapConfig(Bitmap.Config.RGB_565) .resetViewBeforeLoading() .cacheOnDisc() .displayer(new FadeInBitmapDisplayer(740)) .build(); imageLoader.loadImage(ImageUri, defaultOptions, new SimpleImageLoadingListener() { public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) { mImage.setImageDrawable(new BitmapDrawable(mContext.getResources() , getDesiredBitmap(loadedImage, 12))); } }); } private Bitmap getDesiredBitmap(Bitmap originalImage, int roundValue) { // Create required bitmaps Bitmap shadowBitmap = BitmapFactory.decodeResource(mContext.getResources() , R.drawable.samsungapps_thumb_shadow); Bitmap outputBitmap = Bitmap.createBitmap(originalImage.getWidth() , originalImage.getHeight() + 80, Bitmap.Config.ARGB_8888); // Create canvas and pass bitmap to it Canvas mCanvas = new Canvas(outputBitmap); // And finally draw the shaodw mCanvas.drawBitmap(Bitmap.createScaledBitmap(shadowBitmap, originalImage.getWidth() , (int)(shadowBitmap.getHeight() / 2.3), false), 0, originalImage.getHeight(), null); mCanvas.drawBitmap(originalImage, 0, 0, null); return outputBitmap; } } </code></pre> <hr> <p>Any idea about how to accomplish these two things?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload