Androidモバイルアニメーション

836 ワード

private void moveToSelected(int selectIndex) {
		TranslateAnimation animation = new TranslateAnimation(getStartLocal(),
				getEndLocal(selectIndex), 0, 0);
		animation.setDuration(300);
		animation.setFillAfter(true);
		imageView_cursor.startAnimation(animation);
		mCurIndex = selectIndex;
	}

	private int getStartLocal() {
		final ImageButton curTextView = (ImageButton) mViews.get(mCurIndex);
		int startMid = curTextView.getLeft() + curTextView.getWidth() / 2;
		int startLeft = startMid - imageView_cursor.getWidth() / 2;
		return startLeft;
	}

	private int getEndLocal(int selectIndex) {
		final ImageButton toTextView = (ImageButton) mViews.get(selectIndex);
		int endMid = toTextView.getLeft() + toTextView.getWidth() / 2;
		int endLeft = endMid - imageView_cursor.getWidth() / 2;
		return endLeft;
	}