Take the 2-minute tour ×

Is there any way to create a custom image, and then place it into a layout you have?

share|improve this question

2 Answers 2

Yes, you can use an ImageView.

Example xml:


Then you would just stick my_image.png into res/drawable.

Edit - to draw dynamically you want to subclass View and override onDraw(Canvas) with a custom drawing method.

The other option is to load multiple images into res/drawable and choose between them in your Java code:

ImageView image = (ImageView) findViewById(R.id.image);
share|improve this answer
Thanks, I guess I needed to be more clear though. I need to draw a custom image based on user input and then place it into a layout like you have above –  au789 Mar 7 '11 at 11:38

Just what Matthew said. Also if you meant to place the image as the layout background you can do it like


where "background" is an image like background.png placed in the res/drawable folder.

share|improve this answer

Your Answer


