Example usage for android.widget HorizontalScrollView getX

List of usage examples for android.widget HorizontalScrollView getX

Introduction

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

Prototype

@ViewDebug.ExportedProperty(category = "drawing")
public float getX() 

Source Link

Document

The visual x position of this view, in pixels.

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   w  w  w  .j a  v  a 2  s  .  co 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;
}