Android的画廊般的图像滑块 [英] Android Gallery like image slider
本文介绍了Android的画廊般的图像滑块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有图像的列表。我想该用户可以通过滑动左侧和右侧看到的影像。我知道画廊的看法,但我想是这样建在用户滑动图像的Android图库应用程序。
I have list of images. I want that user can see images by sliding left and right. I know about Gallery view but I want something like built in Android Gallery application where user slides images.
推荐答案
尝试使用翻转在code ...
Try to use Flipper in your code...
flipper = (ViewFlipper) findViewById(R.id.flipper);
LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
int layouts[] = new int[]{ R.layout.first, R.layout.second, R.layout.third, R.layout.fourth,
R.layout.fifth, R.layout.sixth, R.layout.seventh, R.layout.eighth, R.layout.nineth, R.layout.tenth,
R.layout.eleventh, R.layout.twelveth, R.layout.thirteen };
for (int layout : layouts)
flipper.addView(inflater.inflate(layout, null));
所有的幻灯片在XML描述的......
all slides are described in xml....
public boolean onTouch(View view, MotionEvent event)
{
switch (event.getAction())
{
case MotionEvent.ACTION_DOWN:
fromPosition = event.getX();
break;
case MotionEvent.ACTION_UP:
float toPosition = event.getX();
if (fromPosition > toPosition)
{
flipper.setInAnimation(AnimationUtils.loadAnimation(this,R.anim.go_next_in));
flipper.setOutAnimation(AnimationUtils.loadAnimation(this,R.anim.go_next_out));
flipper.showNext();
}
else if (fromPosition < toPosition)
{
flipper.setInAnimation(AnimationUtils.loadAnimation(this,R.anim.go_prev_in));
flipper.setOutAnimation(AnimationUtils.loadAnimation(this,R.anim.go_prev_out));
flipper.showPrevious();
}
default:
break;
}
return true;
}
滑动
这篇关于Android的画廊般的图像滑块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文