How to draw an image on top of another drawable?

Put your problem here if it does not fit any of the other categories.

How to draw an image on top of another drawable?

Postby lgmcben » Mon Dec 01, 2008 8:43 am

Hi.

I'm playing with the Home sample (the one that is bundled with the SDK)

I can change the Home screen background using this:


getWindow().setBackgroundDrawable(image_mountain);

Now I have a mountain as a background of my Home screen.

Now let's assume I have a picture of a moon. (image_moon)



Question: Is it possible to...

1. programmatically put the moon on my mountain image.
2. then set the new drawable: "Mountain with the Moon on top" as my Home screen background?

I've explored the LayerDrawable class but it doesn't seem to solve my problem.

Thank you in advance.
lgmcben
Junior Developer
Junior Developer
 
Posts: 24
Joined: Mon Nov 17, 2008 5:06 am

Top

Postby MrSnowflake » Mon Dec 01, 2008 10:53 am

Make a Bitmap or Canvas from the earth and draw the moon over it, then (save it to a file and use that to) set it as background.
User avatar
MrSnowflake
Moderator
Moderator
 
Posts: 1439
Joined: Sat Feb 16, 2008 3:11 pm
Location: Flanders, Belgium

Postby androooooid » Tue Dec 02, 2008 10:48 pm

MrSnowflake wrote:Make a Bitmap or Canvas from the earth and draw the moon over it, then (save it to a file and use that to) set it as background.


There is no way to do it programatically as that would be kind of inefficient and not dynamic?
androooooid
Junior Developer
Junior Developer
 
Posts: 17
Joined: Fri Sep 26, 2008 8:47 pm

Postby MrSnowflake » Wed Dec 03, 2008 11:06 am

Of course there's another way, but then you have to use a Canvas, or maybe override the paint of the main layoutview of your activity.
User avatar
MrSnowflake
Moderator
Moderator
 
Posts: 1439
Joined: Sat Feb 16, 2008 3:11 pm
Location: Flanders, Belgium

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: No registered users and 10 guests