2015-10-20 53 views
0

我可以使用哪種解決方案在將每個字母繪製到畫布之前製作動畫?四,搜索互聯網,我似乎沒有看到任何合理的...Android LiveWallpaper動畫製圖

private void draw() { 
     SurfaceHolder holder = getSurfaceHolder(); 
     Canvas canvas = null; 
     try { 
      canvas = holder.lockCanvas(); 
      if (canvas != null) { 

       // Draw background 
       canvas.drawColor(PrefService.getBgColor());         

       StaticLayout textLayout = new StaticLayout(TEXT_I_WOULD_LIKE_TO_ANIMATE, textPaint, screenWidth - screenWidth/8, Layout.Alignment.ALIGN_CENTER, 1.0F, 1.0F, true); 
       canvas.translate((screenWidth/2) - (textLayout.getWidth()/2), (screenHeight/2) - ((textLayout.getHeight()/2))); 
       textLayout.draw(canvas); 
      } 
     } finally { 
      if (canvas != null) {    
        holder.unlockCanvasAndPost(canvas);     
      } 
     } 
    } 
    handler.removeCallbacks(drawRunner); 
    handler.postDelayed(drawRunner, 20000); 
} 

注意TEXT_I_WOULD_LIKE_TO_ANIMATE變量上面StaticLayout

任何幫助,不勝感激

回答

0

創建一個至極渲染線程你循環你繪製方法。然後,您可以爲文本變量創建位置並更改每幀的文本位置。要在畫布上繪製文本,應使用canvas.drawText(...)。 我希望我能幫助你。