public void updateViewsPositions(float percentX, float percentY) { if (shuffle != null) { final ShuffleSettings shuffleSettings = shuffle.getShuffleSettings(); float percent = shuffleSettings.isVertical() ? percentY : percentX; int numberOfCards = shuffleSettings.getNumberOfDisplayedCards(); for (int i = 1; i < numberOfCards; ++i) { DraggableView view = shuffle.getDraggableView(i); float myScale = shuffleSettings.getScaleForPosition(i); float nextScale = shuffleSettings.getScaleForPosition(i - 1); float percentAbs = myScale + (nextScale - myScale) * Math.abs(percent); ViewCompat.setScaleX(view, percentAbs); ViewCompat.setScaleY(view, percentAbs); float myTranslationY = shuffleSettings.getTranslationYForPosition(i); if (shuffleSettings.isStackFromTop()) { myTranslationY *= -1; } float nextTranslationY = shuffleSettings.getTranslationYForPosition(i - 1); if (shuffleSettings.isStackFromTop()) { nextTranslationY *= -1; } float translationY = myTranslationY - Math.abs(percent) * (myTranslationY - nextTranslationY); ViewCompat.setTranslationY(view, translationY); float myTranslationX = shuffleSettings.getTranslationXForPosition(i); float nextTranslationX = shuffleSettings.getTranslationXForPosition(i - 1); float translationX = myTranslationX - Math.abs(percent) * (myTranslationX - nextTranslationX); ViewCompat.setTranslationX(view, translationX); } } }
ViewCompat.setTranslationY(lastCard, 0); float translationX = shuffleSettings.getTranslationXForPosition(position); ViewCompat.setTranslationX(lastCard, translationX);