Android 如何使用动画使图像像吃角子老虎机一样滚动?
我有静态的ImageView,当我点击一个按钮时,它的内容会随机改变。 如何使图像像这样滚动: 我在以下位置使用Android Wheel: 我的适配器:Android 如何使用动画使图像像吃角子老虎机一样滚动?,android,animation,Android,Animation,我有静态的ImageView,当我点击一个按钮时,它的内容会随机改变。 如何使图像像这样滚动: 我在以下位置使用Android Wheel: 我的适配器: private class SlotMachineAdapter extends AbstractWheelAdapter { // Layout inflater private Context context; /** * Constructor */ public SlotMach
private class SlotMachineAdapter extends AbstractWheelAdapter {
// Layout inflater
private Context context;
/**
* Constructor
*/
public SlotMachineAdapter(Context context) {
this.context = context;
}
@Override
public int getItemsCount() {
return arrImgList.size();
}
// Layout params for image view
final ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
@Override
public View getItem(int index, View cachedView, ViewGroup parent) {
ImageView img;
if (cachedView != null) {
img = (ImageView) cachedView;
} else {
img = new ImageView(context);
}
img.setLayoutParams(params);
Bitmap bitmap = BitmapFactory.decodeFile(arrImgList.get(index));
Bitmap scaled = Bitmap.createScaledBitmap(bitmap, widthWheel, heightWheel, true);
bitmap.recycle();
img.setImageBitmap(scaled);
return img;
}
}
我想要这样的图像改变效果。谢谢先生。我不能使用gif,因为我的图像是由用户添加的。你试过jquery动画吗?我是初级开发人员,我不知道如何使用动画。让我搜索jqueryanimate。请做研究并在这里发布您的答案。
Bitmap bmImg = BitmapFactory.decodeFile(arrImgList.get(pickedNumber));
img.setImageBitmap(bmImg);
private class SlotMachineAdapter extends AbstractWheelAdapter {
// Layout inflater
private Context context;
/**
* Constructor
*/
public SlotMachineAdapter(Context context) {
this.context = context;
}
@Override
public int getItemsCount() {
return arrImgList.size();
}
// Layout params for image view
final ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
@Override
public View getItem(int index, View cachedView, ViewGroup parent) {
ImageView img;
if (cachedView != null) {
img = (ImageView) cachedView;
} else {
img = new ImageView(context);
}
img.setLayoutParams(params);
Bitmap bitmap = BitmapFactory.decodeFile(arrImgList.get(index));
Bitmap scaled = Bitmap.createScaledBitmap(bitmap, widthWheel, heightWheel, true);
bitmap.recycle();
img.setImageBitmap(scaled);
return img;
}
}