0

In my live wallpaper, I am drawing bitmaps on a canvas which cycle every frame to create an animation. I want to show pop up notifications on the screen, so that they appear in front of the background animated wallpaper. I am not using any layouts for the canvas. So if I were to use layouts, how can i stack the background canvas and foreground pop up image?

Thanks, Mukul

1 Answer 1

0

you've just described a framelayout. http://developer.android.com/reference/android/widget/FrameLayout.html

<FrameLayout>
     android:layout_height="wrap_content"
     android:layout_width="wrap_content"

     <BackgroundCanvas/>
     <ForegroundPopup/>
</FrameLayout>

In this case, your Background canvas would be the first thing in your framelayout (your base) and everything afterwards would be stacked on top of it. If you have anymore questions feel free to ask :)

3
  • Cool, but how do i add the canvas to the frame layout hierarchy? I am using an ImageView for the pop up image and setting its background to a 'drawable' resource. My canvas is drawn upon every frame with bitmap.
    – mukul
    Aug 20, 2015 at 20:04
  • I assume your canvas is a custom view? if not, Make it a custom view and then use it in the framelayout.
    – cj1098
    Aug 20, 2015 at 20:06
  • Ok thanks, i will try that. Currently i am using Surfaceholder.lockcanvas() to get canvas to draw. So, not sure how can i make this as a custom view. Custom view has its own onDraw() calls, however i am drawing on canvas inside my Wallpaper service engine draw calls. So should i migrate all drawing to custom view's onDraw()? Sorry, i am relatively new to Android development.
    – mukul
    Aug 21, 2015 at 15:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.