1 回答

TA貢獻1898條經驗 獲得超8個贊
首先,您應該參考您的TestView布局。
public class EyeTestActivity extends AppCompatActivity {
private GestureDetectorCompat mDetector;
private TestView tv;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
tv = new TestView(this);
setContentView(tv);
// get the gesture detector
mDetector = new GestureDetectorCompat(EyeTestActivity.this, new SwipeGestureDetector());
}
然后,在您的onScroll事件中,您應該測試e2而不是e1
@Override
public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) {
if (e2.getAction() == MotionEvent.ACTION_MOVE) {
z++;
if (z >= 120) { // zero based arraylist, so, >= 120
z = 0;
}
tv.invalidate; // this to redraw the point
}
return true;
}
我認為你createPointList沒有做你想做的事。您正在創造 120 次相同的點!總計 120 * 5 * 24 = 14.400 點!
它應該是
for (int i = 1; i <= 5; i++) {
float a = 100 * i;
float b = 100 * i;
for (int j = 1; j <= 24; j++) {
float x = (float) (a * Math.sin(Math.toRadians(15 * j)));
float y = (float) (b * Math.cos(Math.toRadians(15 * j)));
pointlist.add(new Point((int)x, (int)y));
}
}
添加回答
舉報