I have 3 images that I want to add one after other on a canvas. This is my code:-
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
ImageButton im1 = (ImageButton)findViewById(R.id.btnPN);
im1.setBackgroundDrawable(getImage());
}
public BitmapDrawable getImage()
{
Drawable image1 = getResources().getDrawable(R.drawable.imagename);
Drawable image2 = getResources().getDrawable(R.drawable.imagename);
Drawable image3 = getResources().getDrawable(R.drawable.imagename);
Bitmap bitmap = Bitmap.createBitmap(image1.getIntrinsicWidth()
+image2.getIntrinsicWidth()+image3.getIntrinsicWidth(),
image1.getIntrinsicHeight(),Bitmap.Config.ALPHA_8);
Canvas canvas = new Canvas(bitmap);
image1.setBounds(0, 0, image1.getIntrinsicWidth(), image1.getIntrinsicHeight());
image1.draw(canvas);
image2.setBounds(image1.getIntrinsicWidth(), 0, image2.getIntrinsicWidth(),
image2.getIntrinsicHeight());
image2.draw(canvas);
image3.setBounds(image1.getIntrinsicWidth()+image2.getIntrinsicWidth(),
0, image3.getIntrinsicWidth(),
image3.getIntrinsicHeight());
image3.draw(canvas);
BitmapDrawable bu = new BitmapDrawable(bitmap);
return bu;
}
but this is not working.
Can someone please tell me what I am doing wrong here.
Thanks, Farha