Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Color;

import android.view.View;

public class Main {
    public static Bitmap createBitmapFromView(View view) {
        // Clear any focus from the view first to remove any cursor
        view.clearFocus();
        Bitmap drawingBitmap = Bitmap.createBitmap(view.getWidth(), view.getHeight(), Bitmap.Config.ARGB_8888);
        drawingBitmap.eraseColor(Color.TRANSPARENT);
        Canvas canvas = new Canvas(drawingBitmap);
        view.draw(canvas);
        return drawingBitmap;
    }
}