터치 및 제스처 감지 API를 사용하는 대신 모든 터치를 직접 처리하는 응용 프로그램이 있습니다. 부동 창이고 작동하는 유일한 방법이기 때문입니다.onTouch의 android setBackgroundColor가 작동하지 않는 경우가 있습니다.
내가하는 일 중 하나는 손가락 아래에서보기의 색상을 변경하는 것입니다.
myView.setBackgroundColor(getResources().getColor(R.color.white));
나는 현재 옆에있는보기로 이동하고 매우 빠르게 돌아올 때 그것은 작동하지 않습니다 OnTouch 나는이 다른 경우 이전의 내가 실행에서 손가락 아래에있는보기 확인.
로그로 확인했는데 발견 된보기가 정확합니다. 그리고 또한 체크하고 setBackgroundColor가있는 행이 실행됩니다.
그래서 무엇을해야할지 모르겠습니다. setBackgroundColor가 작동하지 않는 경우가 있습니까? onTouch가 실행하는 데 너무 많은 시간이 걸리면 작업이 완료되지 않습니까?
해결 방법에 대한 단서가 있습니까?
편집 : 현재보기 옆에 가서 빨리 돌아올 때만 오류가 발생합니다. 코드를 추가하지 않은 이유는 내가 추상화 한 것보다 읽기가 더 힘들다고 생각했기 때문입니다. 나는 그것을 정리하고 게시했다. 호출 된 메소드가 관련 있다고 생각되면 추가 할 수 있습니다. EDIT 2 : ACTION이 ACTION_DOWN 또는 ACTION_UP이 아닌 경우 실행되는 코드. 그러한 경우는 관련이 없습니다.
if ((isPortrait && isPortraitMeasured) || (!isPortrait && isLandscapeMeasured)) {
//Log.d("algor", "Here calculate where it is");
final int lastCol = currentColumn;
final int lastRow = currentRow;
findCell((int) event.getRawX(), (int) event.getRawY());
if ((lastCol == currentColumn && lastRow == currentRow)) {
if (isPortrait && currentRow==-1 || (!isPortrait && currentColumn==-1)
&& !wasPressed && currentTable!=mainTable) {
//is actionBar. Check if finger is over back icon, to go back
//Code not related to the problem...
}
} else {
int currentIndex = getAppsListIndex();
if (currentIndex >= 0) {
View nextApp;
if (isPortrait)
nextApp = cellsP.get(currentTable).get(currentIndex);
else
nextApp = cellsL.get(currentTable).get(currentIndex);
final Object tag = nextApp.getTag();
if (tag instanceof FolderData) {
//Code not related to the problem...
} else {
Log.d("fastf", "time to change color");
//nextApp.setBackgroundColor(getResources().getColor(R.color.white));
nextApp.setBackgroundColor(whiteColor);
//nextApp.setBackground(getResources().getDrawable(R.color.white));
/*final View app = nextApp;
app.post(new Runnable() {
@Override
public void run() {
app.setBackgroundColor(getResources().getColor(R.color.white));
}
});*/
}
} else {
//Code not related to the problem...
}
int lastIndex = getAppsIndexFromInts(lastRow, lastCol);
//lastCol != -2 is because otherwise, on opening the launcher it animates
// the last app launched
if (lastIndex >= 0 && lastCol != -2) {
View lastApp;
if (isPortrait)
lastApp = cellsP.get(currentTable).get(lastIndex);
else
lastApp = cellsL.get(currentTable).get(lastIndex);
ObjectAnimator animator = ObjectAnimator.ofInt(lastApp,
"backgroundColor", getResources().getColor(R.color.clear_gray),
getResources().getColor(R.color.white_overlay_transition));
animator.setDuration(500);
animator.setEvaluator(new ArgbEvaluator());
animator.start();
}
}
}
getResources(). getColor는이 값을 오래 걸리며 캐시합니다. – pskink
오래 걸리지 않았습니다. 나는 그것을 캐쉬했다. – lotdrops
어디에서 myView.setBackgroundColo를 호출합니까? – pskink