Android ImageViews are animated by Ken Burns Effect.
private void initializeKenBurnsView(){
// KenBurnsView
final KenBurnsView kenBurnsView = (KenBurnsView) findViewById(R.id.ken_burns_view);
// kenBurnsView.setScaleType(ImageView.ScaleType.CENTER_CROP);
// File path, or a uri or url
List<String> urls = Arrays.asList(SampleImages.IMAGES_URL);
kenBurnsView.loadStrings(urls);
// ResourceID
//List<Integer> resourceIDs = Arrays.asList(SampleImages.IMAGES_RESOURCE);
//kenBurnsView.loadResourceIDs(resourceIDs);
// MIX (url & id)
//List<Object> mixingList = Arrays.asList(SampleImages.IMAGES_MIX);
//kenBurnsView.loadMixing(mixingList);
// LoopViewListener
LoopViewPager.LoopViewPagerListener listener = new LoopViewPager.LoopViewPagerListener() {
@Override
public View OnInstantiateItem(int page) {
TextView counterText = new TextView(getApplicationContext());
counterText.setText(String.valueOf(page));
return counterText;
}
@Override
public void onPageScroll(int position, float positionOffset, int positionOffsetPixels) {
}
@Override
public void onPageSelected(int position) {
kenBurnsView.forceSelected(position);
}
@Override
public void onPageScrollChanged(int page) {
}
};
// LoopView
LoopViewPager loopViewPager = new LoopViewPager(this, urls.size(), listener);
//LoopViewPager loopViewPager = new LoopViewPager(this, resourceIDs.size(), listener);
//LoopViewPager loopViewPager = new LoopViewPager(this, mixingList.size(), listener);
FrameLayout viewPagerFrame = (FrameLayout) findViewById(R.id.view_pager_frame);
viewPagerFrame.addView(loopViewPager);
kenBurnsView.setPager(loopViewPager);
}
You should check sample code.
repositories {
jcenter()
}
dependencies {
compile 'com.github.goka.kenburnsview:library:1.0.3'
}
Easy to use
Delete unneeded resources.
Fix initializing size.
Enable to load images from res. Enable to mix. (Enable to load images from url & res)
Thanks for Glide