Is it possible to get these values programmatically:
onDraw()
is called if the whole View is invalidated immediately.1) Here is how I'm counting fps:
public class MyView extends View {
private int mFPS = 0; // the value to show
private int mFPSCounter = 0; // the value to count
private long mFPSTime = 0; // last update time
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
if (SystemClock.uptimeMillis() - mFPSTime > 1000) {
mFPSTime = SystemClock.uptimeMillis();
mFPS = mFPSCounter;
mFPSCounter = 0;
} else {
mFPSCounter++;
}
String s = "FPS: " + mFPS;
canvas.drawText(s, x, y, paint);
invalidate();
}
}
or just write your own object that would calculate this for you :)...
2) Try using
Log.d(tag, "onDraw() is called");
in your onDraw() method.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With