是否可以通过编程方式获取这些值:
每秒
onDraw()
方法。 最佳答案
1)这是我计算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();
}
}
或只是编写您自己的对象即可为您计算:)...
2)尝试使用
Log.d(tag, "onDraw() is called");
在您的onDraw()方法中。
关于每秒Android帧数,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/28967728/