下面列出了android.widget.HorizontalScrollView#getChildAt ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
/**
* 通过 HorizontalScrollView 绘制为 Bitmap
* @param scrollView {@link HorizontalScrollView}
* @param config {@link Bitmap.Config}
* @return {@link Bitmap}
*/
public static Bitmap snapshotByHorizontalScrollView(final HorizontalScrollView 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, "snapshotByHorizontalScrollView");
}
return null;
}