0
현재 매우 집중적 인 그림을 그리는 라이브 배경 화면에 문제가 있습니다. 그러나 내 코드를 테스트 할 때 화면이 느려지고 화면이 회전하면 파손됩니다. 40 사각형 지속적이다라이브 월페이퍼 성능 문제
이mRectArray = new Rect[] {
new Rect(0, 0, c.getWidth(),
(c.getHeight() + statusBarHeight)/20),
new Rect(0, (c.getHeight() + statusBarHeight)/20,
c.getWidth(),
(c.getHeight() + statusBarHeight)/20 * 2),
new Rect(0, (c.getHeight() + statusBarHeight)/20 * 2,
c.getWidth(),
(c.getHeight() + statusBarHeight)/20 * 3),
new Rect(0, (c.getHeight() + statusBarHeight)/20 * 3,
c.getWidth(),
(c.getHeight() + statusBarHeight)/20 * 4),
new Rect(0, (c.getHeight() + statusBarHeight)/20 * 4,
c.getWidth(),
(c.getHeight() + statusBarHeight)/20 * 5),
new Rect(0, (c.getHeight() + statusBarHeight)/20 * 5,
c.getWidth(),
(c.getHeight() + statusBarHeight)/20 * 6),
new Rect(0, (c.getHeight() + statusBarHeight)/20 * 6,
c.getWidth(),
(c.getHeight() + statusBarHeight)/20 * 7),
new Rect(0, (c.getHeight() + statusBarHeight)/20 * 7,
c.getWidth(),
(c.getHeight() + statusBarHeight)/20 * 8),
new Rect(0, (c.getHeight() + statusBarHeight)/20 * 8,
c.getWidth(),
(c.getHeight() + statusBarHeight)/20 * 9),
new Rect(0, (c.getHeight() + statusBarHeight)/20 * 9,
c.getWidth(),
(c.getHeight() + statusBarHeight)/20 * 10),
new Rect(0, (c.getHeight() + statusBarHeight)/20 * 10,
c.getWidth(),
(c.getHeight() + statusBarHeight)/20 * 11),
new Rect(0, (c.getHeight() + statusBarHeight)/20 * 11,
c.getWidth(),
(c.getHeight() + statusBarHeight)/20 * 12),
new Rect(0, (c.getHeight() + statusBarHeight)/20 * 12,
c.getWidth(),
(c.getHeight() + statusBarHeight)/20 * 13),
new Rect(0, (c.getHeight() + statusBarHeight)/20 * 13,
c.getWidth(),
(c.getHeight() + statusBarHeight)/20 * 14),
new Rect(0, (c.getHeight() + statusBarHeight)/20 * 14,
c.getWidth(),
(c.getHeight() + statusBarHeight)/20 * 15),
new Rect(0, (c.getHeight() + statusBarHeight)/20 * 15,
c.getWidth(),
(c.getHeight() + statusBarHeight)/20 * 16),
new Rect(0, (c.getHeight() + statusBarHeight)/20 * 16,
c.getWidth(),
(c.getHeight() + statusBarHeight)/20 * 17),
new Rect(0, (c.getHeight() + statusBarHeight)/20 * 17,
c.getWidth(),
(c.getHeight() + statusBarHeight)/20 * 18),
new Rect(0, (c.getHeight() + statusBarHeight)/20 * 18,
c.getWidth(),
(c.getHeight() + statusBarHeight)/20 * 19),
new Rect(0, (c.getHeight() + statusBarHeight)/20 * 19,
c.getWidth(),
(c.getHeight() + statusBarHeight)/20 * 20),
new Rect(0, 0, right1,
(c.getHeight() + statusBarHeight)/20),
new Rect(0, (c.getHeight() + statusBarHeight)/20, right2,
(c.getHeight() + statusBarHeight)/20 * 2),
new Rect(0, (c.getHeight() + statusBarHeight)/20 * 2,
right3, (c.getHeight() + statusBarHeight)/20 * 3),
new Rect(0, (c.getHeight() + statusBarHeight)/20 * 3,
right4, (c.getHeight() + statusBarHeight)/20 * 4),
new Rect(0, (c.getHeight() + statusBarHeight)/20 * 4,
right5, (c.getHeight() + statusBarHeight)/20 * 5),
new Rect(0, (c.getHeight() + statusBarHeight)/20 * 5,
right6, (c.getHeight() + statusBarHeight)/20 * 6),
new Rect(0, (c.getHeight() + statusBarHeight)/20 * 6,
right7, (c.getHeight() + statusBarHeight)/20 * 7),
new Rect(0, (c.getHeight() + statusBarHeight)/20 * 7,
right8, (c.getHeight() + statusBarHeight)/20 * 8),
new Rect(0, (c.getHeight() + statusBarHeight)/20 * 8,
right9, (c.getHeight() + statusBarHeight)/20 * 9),
new Rect(0, (c.getHeight() + statusBarHeight)/20 * 9,
right10,
(c.getHeight() + statusBarHeight)/20 * 10),
new Rect(0, (c.getHeight() + statusBarHeight)/20 * 10,
right11,
(c.getHeight() + statusBarHeight)/20 * 11),
new Rect(0, (c.getHeight() + statusBarHeight)/20 * 11,
right12,
(c.getHeight() + statusBarHeight)/20 * 12),
new Rect(0, (c.getHeight() + statusBarHeight)/20 * 12,
right13,
(c.getHeight() + statusBarHeight)/20 * 13),
new Rect(0, (c.getHeight() + statusBarHeight)/20 * 13,
right14,
(c.getHeight() + statusBarHeight)/20 * 14),
new Rect(0, (c.getHeight() + statusBarHeight)/20 * 14,
right15,
(c.getHeight() + statusBarHeight)/20 * 15),
new Rect(0, (c.getHeight() + statusBarHeight)/20 * 15,
right16,
(c.getHeight() + statusBarHeight)/20 * 16),
new Rect(0, (c.getHeight() + statusBarHeight)/20 * 16,
right17,
(c.getHeight() + statusBarHeight)/20 * 17),
new Rect(0, (c.getHeight() + statusBarHeight)/20 * 17,
right18,
(c.getHeight() + statusBarHeight)/20 * 18),
new Rect(0, (c.getHeight() + statusBarHeight)/20 * 18,
right19,
(c.getHeight() + statusBarHeight)/20 * 19),
new Rect(0, (c.getHeight() + statusBarHeight)/20 * 19,
right20,
(c.getHeight() + statusBarHeight)/20 * 20),
new Rect(c.getWidth()/20, c.getHeight()/15,
c.getWidth()/20 * 8, c.getHeight()/15 * 4),
new Rect(c.getWidth()/20, c.getHeight()/15,
c.getWidth()/20 * 8, c.getHeight()/15 * 8), };
onDraw는 초기화되고 : 내 그리기 방법 내에서
나는이 있습니다. 이제 문제는
내가 너무 다른 40가 ... 난 사각형의 (20)의 오른쪽 애니메이션을하고있어 이러한 사각형 지속적으로 초기화 할 수 있어야합니다 .. 사각형 애니메이션에 대한 if 문성능을 희생하지 않도록 코드를 압축하는 방법은 무엇입니까 ??
병목 현상을 찾기 위해 프로파일 러를 사용해보십시오. 또한 Rect를 한 번 만들고 속성을 변경할 수 없습니까? 객체를 생성하는 것은 비교적 비싸다. 또한, OpenGL, renderscript 등에 대해 생각해 보자. – Ran
마지막 20 개의 사각형에는 오른쪽에 변수가 있고 각 변수에 애니메이션이 붙어있다. 그러나 메소드에서 한 번 초기화 한 후에 각 사각형을 그릴 때 nullpointerexception과 force close를 얻는다. – Denizen