English 中文(简体)
Android:如何从某种习俗的角度来部分重新思考?
原标题:Android: How to get a custom view to redraw partially?

I have a custom view that fills my entire screen. (A piano keyboard) When a user touches the key, it causes invalidate() to be called and the whole keyboard gets redrawn to show the new state with a touched key.

目前,这种观点非常简单,但我计划增加一个比方更多的冰图。 由于整个键盘是动态的,这将使重整整个键盘更加昂贵。

因此,我认为,请看部分重。 现在我请正确的ir脏区域打上<条码>。 我制定了我的<代码>onDraw(Canvas canvas)方法,如果我确实想要部分重划,则只能从 d脏地区提取钥匙。 这导致这些钥匙被抽取,但其余关键板完全是黑色的,根本不提取。

我错误地期望,在 d脏地区,只有“低”绘画才能“切”目前的<条码>。

我是否能够实现我想要的东西? (a) 通往“海滩”的通道,只能重新划定ir脏区?”

最佳回答

目前的冰层工作是人工处理整个海面,以图绘制:

 private void onDraw(Canvas canvas)
 {
     if (!initialDrawingIsPerformed)
     {
          this.cachedBitmap = Bitmap.createBitmap(getWidth(), getHeight(),
            Config.ARGB_8888); //Change to lower bitmap config if possible.
          Canvas cacheCanvas = new Canvas(this.cachedBitmap);
          doInitialDrawing(cacheCanvas);
          canvas.drawBitmap(this.cachedBitmap, 0, 0, new Paint());
          initialDrawingIsPerformed = true;
     }
     else
     {
          canvas.drawBitmap(this.cachedBitmap, 0, 0, new Paint());
          doPartialRedraws(canvas);
     }
 }

在网上,你需要储存关于哪些是再造的信息,最好不要使用新的<代码>Paint,但这些都是细节。

值得注意的是:比图对你的记忆使用非常沉重。 当我把一种与滚动器使用的观点ched下来时,我就失事了,这相当于装置高度的5倍,因为它使用了“大”的记忆。

问题回答

为了补充Peterdk的回答,你可以节省在电影中的业务,而不是一个比图。

  • A Bitmap will save all pixels, like he said it could take a lot of memory.
  • A Picture will save the calls, like drawRect, drawLine, etc.

这取决于你的申请是否确实很重:大量抽取业务,一些抽取业务,但受重算、许多空白/未使用空间(电影)等控制。





相关问题
Android - ListView fling gesture triggers context menu

I m relatively new to Android development. I m developing an app with a ListView. I ve followed the info in #1338475 and have my app recognizing the fling gesture, but after the gesture is complete, ...

AsyncTask and error handling on Android

I m converting my code from using Handler to AsyncTask. The latter is great at what it does - asynchronous updates and handling of results in the main UI thread. What s unclear to me is how to handle ...

Android intent filter for a particular file extension?

I want to be able to download a file with a particular extension from the net, and have it passed to my application to deal with it, but I haven t been able to figure out the intent filter. The ...

Android & Web: What is the equivalent style for the web?

I am quite impressed by the workflow I follow when developing Android applications: Define a layout in an xml file and then write all the code in a code-behind style. Is there an equivalent style for ...

TiledLayer equivalent in Android [duplicate]

To draw landscapes, backgrounds with patterns etc, we used TiledLayer in J2ME. Is there an android counterpart for that. Does android provide an option to set such tiled patterns in the layout XML?

Using Repo with Msysgit

When following the Android Open Source Project instructions on installing repo for use with Git, after running the repo init command, I run into this error: /c/Users/Andrew Rabon/bin/repo: line ...

Android "single top" launch mode and onNewIntent method

I read in the Android documentation that by setting my Activity s launchMode property to singleTop OR by adding the FLAG_ACTIVITY_SINGLE_TOP flag to my Intent, that calling startActivity(intent) would ...

From Web Development to Android Development

I have pretty good skills in PHP , Mysql and Javascript for a junior developer. If I wanted to try my hand as Android Development do you think I might find it tough ? Also what new languages would I ...

热门标签