2013-03-19 58 views
0

此鏈接:http://www.mediafire.com/view/?hr441qalu6b6d7s位圖上SurfaceView Optomization

指向表明我的位圖的繪製花費很長的時間,導致滯後於我的應用程序的圖像。我如何優化這個以免造成太多滯後。目前我有這個作爲我的畫布方法:

Canvas c = holder.lockCanvas(); 
    Paint p = new Paint(); 
    p.setTextSize(30); 
    p.setColor(Color.BLACK); 
    new handleStuff().execute(""); 
    //Actions End 

    //Background 
    Bitmap scaledBackground = Bitmap.createScaledBitmap(background, this.getWidth(), this.getHeight(), true); 
    c.drawBitmap(scaledBackground, 0, 0, null); 
    //Background End 

我最初的想法是,背景,每一次是什麼原因造成的是滯後的,但我不知道的繪製。

回答

0

把所有的對象創建放在draw方法的外面(所以只需在init/whatever中創建bmp/paint等),然後在draw方法中使用它們。

這會加快速度,減少內存使用並減少垃圾收集......很多。