Java Code Examples for android.widget.LinearLayout#draw()
The following examples show how to use
android.widget.LinearLayout#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: MyTrip.java From Taxi-App-Android-XML with GNU General Public License v3.0 | 6 votes |
public Bitmap getBitmapFromView(String title, int dotBg) { LinearLayout llmarker = (LinearLayout) findViewById(R.id.ll_marker); TextView markerImageView = (TextView) findViewById(R.id.tv_title); markerImageView.setText(title); View dot = (View) findViewById(R.id.dot_marker); dot.setBackgroundResource(dotBg); llmarker.measure(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED); Bitmap bitmap = Bitmap.createBitmap(llmarker.getMeasuredWidth(), llmarker.getMeasuredHeight(), Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(bitmap); llmarker.layout(0, 0, llmarker.getMeasuredWidth(), llmarker.getMeasuredHeight()); llmarker.draw(canvas); return bitmap; }
Example 2
Source File: Home.java From Taxi-App-Android-XML with GNU General Public License v3.0 | 6 votes |
public Bitmap getBitmapFromView(String title, int dotBg) { LinearLayout llmarker = (LinearLayout) findViewById(R.id.ll_marker); TextView markerImageView = (TextView) findViewById(R.id.tv_title); markerImageView.setText(title); View dot = (View) findViewById(R.id.dot_marker); dot.setBackgroundResource(dotBg); llmarker.measure(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED); Bitmap bitmap = Bitmap.createBitmap(llmarker.getMeasuredWidth(), llmarker.getMeasuredHeight(), Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(bitmap); llmarker.layout(0, 0, llmarker.getMeasuredWidth(), llmarker.getMeasuredHeight()); llmarker.draw(canvas); return bitmap; }
Example 3
Source File: ExportToImage.java From microMathematics with GNU General Public License v3.0 | 6 votes |
public void write(FormulaListView formulaListView, Bitmap.CompressFormat format) throws Exception { final LinearLayout f = formulaListView.getList(); Bitmap bitmap = null; try { bitmap = Bitmap.createBitmap(f.getMeasuredWidth(), f.getMeasuredHeight(), Bitmap.Config.ARGB_8888); final Canvas canvas = new Canvas(bitmap); f.setBackgroundColor(CompatUtils.getThemeColorAttr(f.getContext(), android.R.attr.windowBackground)); f.draw(canvas); } catch (OutOfMemoryError e) { throw new Exception(e.getLocalizedMessage()); } finally { f.setBackgroundResource(android.R.color.transparent); } bitmap.compress(format, 100, stream); stream.flush(); }
Example 4
Source File: AppUtils.java From YCWebView with Apache License 2.0 | 5 votes |
/** * 截取LinearLayout **/ public static Bitmap getLinearLayoutBitmap(LinearLayout linearLayout) { int h = 0; Bitmap bitmap; for (int i = 0; i < linearLayout.getChildCount(); i++) { h += linearLayout.getChildAt(i).getHeight(); } // 创建对应大小的bitmap bitmap = Bitmap.createBitmap(linearLayout.getWidth(), h, Bitmap.Config.ARGB_8888); final Canvas canvas = new Canvas(bitmap); linearLayout.draw(canvas); return bitmap; }