Java Code Examples for android.widget.LinearLayout.draw()

The following are Jave code examples for showing how to use draw() of the android.widget.LinearLayout class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: Taxi-App-Android-XML   File: MyTrip.java   View Source Code Vote up 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
Project: Taxi-App-Android-XML   File: Home.java   View Source Code Vote up 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
Project: boohee_v5.6   File: BitmapUtil.java   View Source Code Vote up 6 votes
public static Bitmap getBitmapByView(LinearLayout linearLayout) {
    int h = 0;
    int i = 0;
    while (i < linearLayout.getChildCount()) {
        try {
            if (linearLayout.getChildAt(i).getVisibility() == 0) {
                h += linearLayout.getChildAt(i).getHeight();
            }
            i++;
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }
    }
    Bitmap bitmap = Bitmap.createBitmap(linearLayout.getWidth(), h, Config.ARGB_8888);
    linearLayout.draw(new Canvas(bitmap));
    return bitmap;
}
 
Example 4
Project: microMathematics   File: ExportToImage.java   View Source Code Vote up 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();
}