开发者

How to add Text on Android Live Wallpapers

Im doing Android Live Wallpaper.It provides the user to give text input dyn开发者_如何学编程amically.That text should be displayed on wallpaper or scrolling like that.And this wallpapers have to be set as background.How could i do this.?


You can use this.

final SurfaceHolder holder = getSurfaceHolder();

try {
     Canvas _canvas = holder.lockCanvas();
     if (_canvas != null)
     {
         drawAnimation(_canvas);
     }
}
finally
     {
         if (_canvas != null)
              holder.unlockCanvasAndPost(_canvas);
     }

and then in your drawAnimation function

private void drawAnimation(Canvas c) 
{
    c.drawText(text, x, y, paint);
}

You can use this and you can see if y>height_screen first line replace to second line and after that second line will be a first line. And you can do this for all line, after that you will see that your last line will be empty, add your new text in last line. I hope it helps you.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜