Example usage for android.widget ScrollView getWidth

List of usage examples for android.widget ScrollView getWidth

Introduction

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

Prototype

@ViewDebug.ExportedProperty(category = "layout")
public final int getWidth() 

Source Link

Document

Return the width of your view.

Usage

From source file:com.bobomee.android.common.util.ScreenUtil.java

/**
 * http://blog.csdn.net/lyy1104/article/details/40048329
 *//* ww  w .  j a  va2  s  .  c  om*/
public static Bitmap shotScrollView(ScrollView scrollView) {
    int h = 0;
    Bitmap bitmap = null;
    for (int i = 0; i < scrollView.getChildCount(); i++) {
        h += scrollView.getChildAt(i).getHeight();
        scrollView.getChildAt(i).setBackgroundColor(Color.parseColor("#ffffff"));
    }
    bitmap = Bitmap.createBitmap(scrollView.getWidth(), h, Bitmap.Config.RGB_565);
    final Canvas canvas = new Canvas(bitmap);
    scrollView.draw(canvas);
    return bitmap;
}

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

private void scrollToolBarToTop() {
    ScrollView scrollView = (ScrollView) mSolo.getView(R.id.bottom_bar_landscape_scroll_view);
    int[] screenLocation = { 0, 0 };
    scrollView.getLocationOnScreen(screenLocation);
    int getAwayFromTop = 42;
    float fromY = screenLocation[1] + getAwayFromTop;
    float toY = scrollView.getHeight();
    float xPos = screenLocation[0] + (scrollView.getWidth() / 2.0f);

    mSolo.drag(xPos, xPos, fromY, toY, 1);
}

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 ww w.jav a2  s .  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;
}