Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using a FrameLayout as a Live Wallpaper

I'm trying to use a FrameLayout as the content of a Live Wallpaper. According to this answer by Romain Guy, it should be possible, but I didn't have much luck calling .measure() and .layout() on the view. Could anyone give me a brief example of how to use a regular layout inside a Live Wallpaper?

like image 541
Nick Avatar asked Jul 11 '12 22:07

Nick


1 Answers

It's a wallpaper that you can mess around with, right? If you are going above the usual views, you may have to implement some custom logic, especially if you are drawing images. A FrameLayout has background and foreground drawable functions. You can use XML or Java to add regular views into a FrameLayout

You also can create a custom Drawable object to do a lot of fun things with regards to custom painting. The Drawable object simply gets sent the view's canvas.

If you want to measure views, you are going to have to do it after the view runs through its measure and layout codes. This means doing this in onCreate() returns 0. Lots of people have had better luck doing it in a callback like onWindowFocusedChanged

like image 102
Joe Plante Avatar answered Oct 30 '22 08:10

Joe Plante