TextView textView = new TextView(this);
textView.setText("잠시후 오후 4시 부터 방송을 할 예정입니다. 이번 프로그램은 어쩌고 저쩌고 이므로 많은 시청을 바랍니다.");
textView.setTextSize(50);
textView.setTextColor(Color.RED);
textView.setBackgroundColor(0x770000FF);
textView.setDrawingCacheEnabled(true);
textView.destroyDrawingCache();
textView.buildDrawingCache();
textView.measure( MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED),
MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED));
textView.layout(0, 0, textView.getMeasuredWidth(), textView.getMeasuredHeight());
Bitmap src = textView.getDrawingCache();
if (src == null) Toast.makeText(this, "NULL", Toast.LENGTH_LONG).show();
else {
Bitmap bitmap = getTransparentBitmapCopy(src);
mImage.setImageBitmap(bitmap);
mImage.setScaleType(ImageView.ScaleType.CENTER);
}
private Bitmap getTransparentBitmapCopy(Bitmap source)
{
int width = source.getWidth();
int height = source.getHeight();
Bitmap copy = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
int[] pixels = new int[width * height];
source.getPixels(pixels, 0, width, 0, 0, width, height);
copy.setPixels(pixels, 0, width, 0, 0, width, height);
return copy;
}