Example usage for android.widget ScrollView getChildCount

List of usage examples for android.widget ScrollView getChildCount

Introduction

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

Prototype

public int getChildCount() 

Source Link

Document

Returns the number of children in the group.

Usage

From source file:Main.java

public static Bitmap createBitmap(Context context, ScrollView v) {
    int width = 0, height = 0;
    for (int i = 0; i < v.getChildCount(); i++) {
        width += v.getChildAt(i).getWidth();
        height += v.getChildAt(i).getHeight();
    }/*w  ww.  j  ava  2 s  . c om*/
    if (width <= 0 || height <= 0) {
        return null;
    }
    int h = ((WindowManager) context.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay().getHeight();
    if (height < h)
        height = h;
    Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
    Canvas canvas = new Canvas(bitmap);
    v.draw(canvas);
    return bitmap;
}

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

/**
 * http://blog.csdn.net/lyy1104/article/details/40048329
 *///from w w w  .  j  a  v a2s.co m
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:com.google.reviewit.ReviewChangesFragment.java

private void init() {
    SwipeRefreshLayout swipeRefreshLayout = (SwipeRefreshLayout) v(R.id.swipeRefreshLayout);
    swipeRefreshLayout.setColorSchemeColors(widgetUtil.color(R.color.progressBar));
    swipeRefreshLayout.setRefreshing(true);
    swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
        @Override/*from w  w  w . j a  v a2  s  . c o m*/
        public void onRefresh() {
            getApp().getQueryHandler().reset();
            loadAndDisplay(true);
        }
    });

    v(R.id.reloadButton).setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            reloadQuery();
        }
    });

    final View nextPageProgress = v(R.id.nextPageProgress);
    final ScrollView scrollView = (ScrollView) v(R.id.scrollView);
    scrollView.getViewTreeObserver().addOnScrollChangedListener(new ViewTreeObserver.OnScrollChangedListener() {
        @Override
        public void onScrollChanged() {
            if (isAdded() && getApp().getQueryHandler().hasNext()
                    && nextPageProgress.getVisibility() == View.GONE) {
                View lastChild = scrollView.getChildAt(scrollView.getChildCount() - 1);
                if ((lastChild.getBottom() - (scrollView.getHeight() + scrollView.getScrollY())) == 0) {
                    setVisible(nextPageProgress);
                    scrollView.post(new Runnable() {
                        @Override
                        public void run() {
                            scrollView.fullScroll(View.FOCUS_DOWN);
                            loadAndDisplay();
                        }
                    });
                }
            }
        }
    });
}