I have the following class:
public class TesteMultiImage extends ActionBarActivity {
Uri URI;
String ImagePath;
Button button;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_teste_multi_image);
button = (Button)findViewById(R.id.button3);
SimpleDateFormat sdf = new SimpleDateFormat("ddMMyyyy_HHmm");
final String currentDateandTime = sdf.format(new Date());
final RelativeLayout rl = (RelativeLayout)findViewById(R.id.rl);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
rl.buildDrawingCache();
Bitmap bmap = rl.getDrawingCache();
ImagePath = MediaStore.Images.Media.insertImage(
getContentResolver(),
bmap,
"banner" + currentDateandTime,
"banner"
);
URI = Uri.parse(ImagePath);
Toast.makeText(getApplicationContext(), "Imagem Salva", Toast.LENGTH_LONG).show();
}
});
}
}
It saves my relative layout as a bitmap. But it saves with a black background, and needs to be saved with a transparent background. When trying to configure:
bmap = Bitmap.createBitmap(width, height, Config.ARGB_8888);
It does not work. How to solve?