Moving Android View and preventing onDraw callback over and over

I am expanding the class Viewto what I call MyView. (I added some properties that basically say what is drawn on the object, and handling this)

I move an object of this class every few milliseconds, this works fine. I use this.layout(left, top, right, bottom);to move MyView. But it seems that every time the view moves, it is redrawn (called onDraw). It's necessary? The content MyViewdoes not change when you move it. In fact, the content will never change - it is created in one way, moved, and then destroyed.

I use onDrawit because every time it is created, I want it to draw text or some numbers on it. I used the extension ImageViewand used it setImageResource, but I realized that I want to get more than just different images, and create images for all kinds of text and the amount of content that this object can be immune.

It is also important that my object can receive onTouch events that work great today.

My onDraw method currently contains: (this will change when I get it, so as not to repaint it all the time)

@Override
public void onDraw(Canvas canvas) {
    Paint p = new Paint();
    p.setARGB(255, 0, 255, 255);
    canvas.drawRect(0, 0, 32, 32, p);
}

, : , , ( , ), , ( )?

: ( 100+) , , , .

: , , ?

+2
2

, , , ( onDraw). ?

.

A View onDraw , invalidate , , , .

, ,

, , , onTouchEvent , View a TouchListener

. (100+). , Google , , .

+3

, onDraw , - Android-, ( , ). , - https://plus.google.com/117549329232493334054/posts/FMf8RfhFceC, LayoutTransition.

, , (, ViewPropertyAnimator, ). , "" , . , , LayoutParams , layout.

0

All Articles