Example usage for android.widget HorizontalScrollView canScrollHorizontally

List of usage examples for android.widget HorizontalScrollView canScrollHorizontally

Introduction

In this page you can find the example usage for android.widget HorizontalScrollView canScrollHorizontally.

Prototype

public boolean canScrollHorizontally(int direction) 

Source Link

Document

Check if this view can be scrolled horizontally in a certain direction.

Usage

From source file:org.catrobat.paintroid.test.integration.BaseIntegrationTestClass.java

protected View scrollToToolButton(ToolType toolType) {
    HorizontalScrollView scrollView = (HorizontalScrollView) mSolo.getView(R.id.bottom_bar_scroll_view);
    int scrollRight = 1;
    int scrollLeft = -1;
    View toolButtonView = null;/*from  www. j a  v a  2s  .c  o  m*/

    while (scrollView.canScrollHorizontally(scrollLeft)) {
        scrollToolBarToLeft();
    }

    float scrollPosRight = scrollView.getX() + scrollView.getWidth();
    int[] btnLocation = { 0, 0 };
    getToolButtonView(toolType).getLocationOnScreen(btnLocation);
    float btnPos = btnLocation[0] + (getToolButtonView(toolType).getWidth() / 2.0f);

    if (btnPos < scrollPosRight) {
        toolButtonView = getToolButtonView(toolType);
    }

    while (scrollView.canScrollHorizontally(scrollRight) && toolButtonView == null) {
        mSolo.scrollViewToSide(scrollView, Solo.RIGHT);
        getToolButtonView(toolType).getLocationOnScreen(btnLocation);
        btnPos = btnLocation[0] + (getToolButtonView(toolType).getWidth() / 2.0f);
        if (btnPos < scrollPosRight) {
            toolButtonView = getToolButtonView(toolType);
            break;
        }
    }

    assertNotNull("Tool button not found", toolButtonView);
    return toolButtonView;
}