2010-11-16 60 views
0

我想要在Android中獲取動畫文本,並在屏幕上從左向右運行。例如, 我想要得到這個文本 private static final String QUOTE = 「沒有人再用Java了,它就是這個重量級的重量級的球和鏈。在畫布上顯示動畫時未獲得完整文本:Android,

使用動畫從右向左運行。

但是,這段文字被截斷爲「沒有人使用Java了,它是」在肖像模式下,並且在 「沒有人再使用Java了,它是橫向模式下的這個大重量級人物。

這是我曾經用過

 Paint paint = new Paint(); 
     paint.setColor(Color.BLUE); 
     private static final String QUOTE = 
     "Nobody uses Java anymore. It's this big heavyweight ball and chain."; 
     paint.setTextSize(20); 
     paint.setAntiAlias(true); 
     int len= QUOTE.length(); 
     canvas.scale(1,-1); 
     canvas.drawText(QUOTE, 0, len-1, 100, 60, paint); 
     canvas.drawText(QUOTE,0,100 , paint); 
     createAnim(canvas); 


      private void createAnim(Canvas canvas) { 

     anim2= new TranslateAnimation(500,-500,30,30); 
     anim2.setRepeatCount(Animation.INFINITE); 
     anim2.setInterpolator(new AccelerateDecelerateInterpolator()); 
     anim2.setRepeatMode(Animation.RESTART); 
     anim2.setDuration(1000L); 
     startAnimation(anim2); 

      } 

回答

0

請檢查高度和帆布的寬度,

// Custom Font Text 
      Bitmap bitmap = Bitmap.createBitmap((int) getWindowManager() 
        .getDefaultDisplay().getWidth(), 
        (int) getWindowManager().getDefaultDisplay() 
          .getHeight()/2, Bitmap.Config.ARGB_8888); 
      canvas = new Canvas(bitmap); 
      drawingImageView.setImageBitmap(bitmap); 
      paint = new Paint(); 
      paint.setColor(Color.BLACK); 
      paint.setTextSize(150); 
      Typeface chops = Typeface.createFromAsset(this.getAssets(), 
        "WC_Speed_Bold_Bta.ttf"); 
      paint.setTypeface(chops); 
      int xPos = (canvas.getWidth()/2); 
      int yPos = (int) ((canvas.getHeight()/2) - ((paint.descent() + paint 
        .ascent())/2)); 
      canvas.drawText("Hello", xPos, yPos, paint);