Example usage for android.widget ScrollView draw

List of usage examples for android.widget ScrollView draw

Introduction

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

Prototype

@Override
    public void draw(Canvas canvas) 

Source Link

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();
    }/*from   w w  w. j  a v a  2  s.  co m*/
    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
 *//*  w w  w.  j a  v a2 s .c o 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;
}