Java Code Examples for android.widget.ScrollView#draw()
The following examples show how to use
android.widget.ScrollView#draw() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CapturePictureUtils.java From DevUtils with Apache License 2.0 | 6 votes |
/** * 通过 ScrollView 绘制为 Bitmap * <pre> * ScrollView 容器中不能有诸如 ListView、GridView、WebView 这样的高度可变的控件 * </pre> * @param scrollView {@link ScrollView} * @param config {@link Bitmap.Config} * @return {@link Bitmap} */ public static Bitmap snapshotByScrollView(final ScrollView scrollView, final Bitmap.Config config) { if (scrollView == null || config == null) return null; try { View view = scrollView.getChildAt(0); int width = view.getWidth(); int height = view.getHeight(); Bitmap bitmap = Bitmap.createBitmap(width, height, config); Canvas canvas = new Canvas(bitmap); canvas.drawColor(BACKGROUND_COLOR); scrollView.layout(0, 0, scrollView.getMeasuredWidth(), scrollView.getMeasuredHeight()); scrollView.draw(canvas); return bitmap; } catch (Exception e) { LogPrintUtils.eTag(TAG, e, "snapshotByScrollView"); } return null; }
Example 2
Source File: LongImageUtils.java From SuperNote with GNU General Public License v3.0 | 6 votes |
/** * 截取scrollview的屏幕 **/ public static Bitmap getScrollViewBitmap(ScrollView scrollView) { int h = 0; Bitmap bitmap; for (int i = 0; i < scrollView.getChildCount(); i++) { h += scrollView.getChildAt(i).getHeight(); } // 创建对应大小的bitmap bitmap = Bitmap.createBitmap(ScreenUtils.getScreenWidth(), h, Bitmap.Config.ARGB_4444); final Canvas canvas = new Canvas(bitmap); canvas.drawColor(Color.parseColor("#f2f7fa")); scrollView.draw(canvas); return bitmap; }
Example 3
Source File: ConvertToBitmapUtil.java From AndroidStudyDemo with GNU General Public License v2.0 | 6 votes |
/** * 将ScrollView转换为Bitmap * @param scrollView * @return */ public static Bitmap convertScrollViewToBitmap(ScrollView scrollView) { int h = 0; Bitmap bitmap = null; // 获取scrollview实际高度 for (int i = 0; i < scrollView.getChildCount(); i++) { h += scrollView.getChildAt(i).getHeight(); scrollView.getChildAt(i).setBackgroundColor( Color.parseColor("#ffffff")); } // 创建对应大小的bitmap bitmap = Bitmap.createBitmap(scrollView.getWidth(), h, Bitmap.Config.RGB_565); final Canvas canvas = new Canvas(bitmap); scrollView.draw(canvas); return bitmap; }
Example 4
Source File: ViewShot.java From zone-sdk with MIT License | 6 votes |
/** * 截取scrollview的屏幕 **/ public static Bitmap getBitmapByScrollView(ScrollView scrollView) { int h = 0; Bitmap bitmap = null; // 获取listView实际高度 for (int i = 0; i < scrollView.getChildCount(); i++) h += scrollView.getChildAt(i).getHeight(); Log.d(TAG, "实际高度:" + h); Log.d(TAG, " 高度:" + scrollView.getHeight()); // 创建对应大小的bitmap bitmap = Bitmap.createBitmap(scrollView.getWidth(), h, Bitmap.Config.ARGB_8888); final Canvas canvas = new Canvas(bitmap); scrollView.draw(canvas); return bitmap; }
Example 5
Source File: ScreenUtils.java From Tok-Android with GNU General Public License v3.0 | 5 votes |
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; }
Example 6
Source File: SaveBitmapUtil.java From OneText_For_Android with GNU Lesser General Public License v3.0 | 5 votes |
/** * 对ScrollView进行截图 * * @param scrollView * @return */ 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; }
Example 7
Source File: RxImage.java From FakeWeather with Apache License 2.0 | 5 votes |
private static Bitmap saveScrollViewToBitmap(ScrollView scrollView) { int h = 0; for (int i = 0; i < scrollView.getChildCount(); i++) { h += scrollView.getChildAt(i).getHeight(); } Bitmap bitmap = Bitmap.createBitmap(scrollView.getWidth(), h, Bitmap.Config.ARGB_8888); final Canvas canvas = new Canvas(bitmap); scrollView.draw(canvas); return bitmap; }
Example 8
Source File: ShareUtil.java From Huochexing12306 with Apache License 2.0 | 5 votes |
/** * 截取scrollview的屏幕 * **/ public static Bitmap getBitmapByView(ScrollView scrollView) { int h = 0; Bitmap bitmap = null; // 获取listView实际高度 for (int i = 0; i < scrollView.getChildCount(); i++) { h += scrollView.getChildAt(i).getHeight(); } // 创建对应大小的bitmap bitmap = Bitmap.createBitmap(scrollView.getWidth(), h, Bitmap.Config.ARGB_8888); final Canvas canvas = new Canvas(bitmap); scrollView.draw(canvas); return bitmap; }
Example 9
Source File: AppUtils.java From YCWebView with Apache License 2.0 | 5 votes |
/** * 截取scrollview的屏幕 * @param scrollView * @return */ public static Bitmap getBitmapByView(ScrollView scrollView) { int h = 0; Bitmap bitmap = null; // 获取listView实际高度 for (int i = 0; i < scrollView.getChildCount(); i++) { h += scrollView.getChildAt(i).getHeight(); scrollView.getChildAt(i).setBackgroundColor(Color.WHITE); } // 创建对应大小的bitmap bitmap = Bitmap.createBitmap(scrollView.getWidth(), h, Bitmap.Config.ARGB_8888); final Canvas canvas = new Canvas(bitmap); scrollView.draw(canvas); return bitmap; }
Example 10
Source File: ScreenUtils.java From BaseProject with Apache License 2.0 | 5 votes |
/** * 截取scrollview的屏幕 * **/ public static Bitmap getScrollViewBitmap(ScrollView scrollView) { int h = 0; Bitmap bitmap; for (int i = 0; i < scrollView.getChildCount(); i++) { h += scrollView.getChildAt(i).getHeight(); } // 创建对应大小的bitmap bitmap = Bitmap.createBitmap(scrollView.getWidth(), h, Bitmap.Config.ARGB_8888); final Canvas canvas = new Canvas(bitmap); scrollView.draw(canvas); return bitmap; }