List of usage examples for android.widget HorizontalScrollView setScrollX
public void setScrollX(int value)
From source file:org.catrobat.paintroid.ui.BottomBar.java
private void startBottomBarAnimation() { final HorizontalScrollView horizontalScrollView = (HorizontalScrollView) mMainActivity .findViewById(R.id.bottom_bar_scroll_view); final ScrollView verticalScrollView = (ScrollView) mMainActivity .findViewById(R.id.bottom_bar_landscape_scroll_view); final int animationDuration = 1000; int orientation = mMainActivity.getResources().getConfiguration().orientation; if (orientation == Configuration.ORIENTATION_PORTRAIT) { horizontalScrollView.post(new Runnable() { public void run() { int scrollToX = (int) (getToolButtonByToolType(mCurrentToolType).getX() - horizontalScrollView.getWidth() / 2.0f + mMainActivity.getResources().getDimension(R.dimen.bottom_bar_button_width) / 2.0f); int scrollFromX = PaintroidApplication.isRTL ? horizontalScrollView.getChildAt(0).getLeft() : horizontalScrollView.getChildAt(0).getRight(); horizontalScrollView.setScrollX(scrollFromX); ObjectAnimator.ofInt(horizontalScrollView, "scrollX", scrollToX).setDuration(animationDuration) .start();/* w ww . j ava 2 s. co m*/ } }); } else if (orientation == Configuration.ORIENTATION_LANDSCAPE) { verticalScrollView.post(new Runnable() { public void run() { int scrollToY = (int) (getToolButtonByToolType(mCurrentToolType).getY() - verticalScrollView.getHeight() / 2.0f + mMainActivity.getResources().getDimension(R.dimen.bottom_bar_landscape_button_height) / 2.0f); int scrollFromY = verticalScrollView.getChildAt(0).getBottom(); verticalScrollView.setScrollY(scrollFromY); ObjectAnimator.ofInt(verticalScrollView, "scrollY", scrollToY).setDuration(animationDuration) .start(); } }); } delayedAnimateSelectedTool(animationDuration); }