开发者

FrameLayout for drawing overlays in a game? Battery?

I've got a game, a custom View class draws my gameboard. I'm thinking of drawing some elements on a separate layer above the gameboard. I could do this in the View's canvas code, but since they won't change frequently, was thinking of introducing a frame layout to display this top layer:

<FrameLayout>
  <LinearLayout /> // game board
  <LinearLayout background="#00000000"/> // stuff like cards, other overlays.
</FrameLayout>

    vs

<LinearLayout /> // game board, draw cards etc on every onDraw() call开发者_C百科 myself.

I'm not sure which route to take, the only reason I wouldn't do the FrameLayout is because I'm not sure if it has an impact on battery life. Everytime onDraw() is called, the system probably has to do an alpha composition of the two layers. Is that more battery consuming than drawing the elements from that layer myself in my canvas on every frame? Hard to answer since I'm not sure how complex the drawing will be yet, any general opinions?

Thanks


Surely alpha composition adds to processor working harder. The question is if this is significant. As you know premature optimisation is evil.

The only way to be sure is to create both (simplified) versions and run a battery test. Android reports pretty reliably how much an app is using battery.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜