如何添加文本在Android上动态壁纸 [英] How to add Text on Android Live Wallpapers

查看:155
本文介绍了如何添加文本在Android上动态壁纸的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Im做Android的直播Wallpaper.It提供用户给出的文本输入dynamically.That文本应显示在墙纸或类似that.And滚动此壁纸拥有可我这样做是为了设置为background.How?

Im doing Android Live Wallpaper.It provides the user to give text input dynamically.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.?

推荐答案

您可以使用此。

final SurfaceHolder holder = getSurfaceHolder();

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

,然后在drawAnimation功能

and then in your drawAnimation function

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

您可以使用这一点,你可以看到,如果Y> height_screen第一线替换为第二行和第二行之后将是第一道防线。你可以为所有行,之后,你会看到你的最后一行将是空的,在最后一行添加新的文字做到这一点。 我希望它可以帮助你。

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.

这篇关于如何添加文本在Android上动态壁纸的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆