Example usage for android.widget ScrollView getY

List of usage examples for android.widget ScrollView getY

Introduction

In this page you can find the example usage for android.widget ScrollView getY.

Prototype

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

Source Link

Document

The visual y position of this view, in pixels.

Usage

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

protected View verticalScrollToToolButton(ToolType toolType) {
    ScrollView scrollView = (ScrollView) mSolo.getView(R.id.bottom_bar_landscape_scroll_view);
    int scrollBottom = 1;
    int scrollTop = -1;
    View toolButtonView = null;//from  w w  w . j  a va  2s . c  o m

    while (scrollView.canScrollVertically(scrollTop)) {
        scrollToolBarToTop();
    }

    float scrollPosBottom = scrollView.getY() + scrollView.getHeight();
    int[] btnLocation = { 0, 0 };
    getToolButtonView(toolType).getLocationOnScreen(btnLocation);
    float btnPos = btnLocation[1] + (getToolButtonView(toolType).getHeight() / 2.0f);

    if (btnPos < scrollPosBottom) {
        toolButtonView = getToolButtonView(toolType);
    }
    float fromX, toX, fromY, toY = 0;
    int stepCount = 20;
    int screenWidth = getActivity().getWindowManager().getDefaultDisplay().getWidth();
    int screenHeight = getActivity().getWindowManager().getDefaultDisplay().getHeight();
    while (scrollView.canScrollVertically(scrollBottom) && toolButtonView == null) {
        fromX = screenWidth - scrollView.getWidth() / 2;
        toX = fromX;
        fromY = screenHeight / 2;
        toY = screenHeight / 4 - screenHeight / 8;
        mSolo.drag(fromX, toX, fromY, toY, stepCount);
        getToolButtonView(toolType).getLocationOnScreen(btnLocation);
        btnPos = btnLocation[1] + (getToolButtonView(toolType).getHeight() / 2.0f);
        if (btnPos < scrollPosBottom) {
            toolButtonView = getToolButtonView(toolType);
            break;
        }
    }

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