gallery setselection 的动画:
//动画效果 public void imageViewAniamtion(int position) { View exit; View enter; if(position == 0){ exit = photo_scanner_gallery.getChildAt(0); enter = photo_scanner_gallery.getChildAt(1); }else if(position == photoList.size() - 1){ return; }else{ exit = photo_scanner_gallery.getChildAt(1); enter = photo_scanner_gallery.getChildAt(2); } exit.startAnimation(AnimationUtils.loadAnimation(this, R.anim.photo_auto_exit)); enter.startAnimation(AnimationUtils.loadAnimation(this, R.anim.photo_auto_enter)); } //调用的地方 private Handler handler = new Handler(){ @Override public void handleMessage(Message msg) { // TODO Auto-generated method stub super.handleMessage(msg); switch(msg.what){ case START: position = photo_scanner_gallery.getSelectedItemPosition(); if(position == photoList.size()-1){ if(scanModel == ORDER){ removeMessages(START); sendEmptyMessage(STOP); break; } } imageViewAniamtion(position); if(position < photoList.size()-1){ position++; }else{ position = 0; } // setCurrentPosition(position); sendEmptyMessageDelayed(START, 5000); break; case STOP: break; default: break; } setCurrentPosition(position);
} }; |
方法2:
gallery中直接使用 xxxx.onKeyDown(KeyEvent.KEYCODE_DPAD_RIGHT, null);