8
喜認爲我需要繪製路徑簡潔的線條,應該寫出來的紅色長方形白色畫布lines.but它不畫了什麼,我缺少什麼M。 我的代碼:如何繪製路徑到Android中
Canvas canvas = new Canvas();
Paint paint = new Paint();
paint.setStyle(Paint.Style.FILL);
paint.setColor(Color.RED);
canvas.drawPaint(paint);
Path path = new Path();
//canvas.drawColor(Color.CYAN);
for (int i = 5; i < 50; i++) {
path.moveTo(4, i-1);
path.lineTo(4, i);
}
path.close();
paint.setStrokeWidth(3);
paint.setPathEffect(null);
paint.setColor(Color.WHITE);
paint.setStyle(Paint.Style.STROKE);
canvas.drawPath(path, paint);
for (int i = 0; i < 3; i++) {
View iview = inflater.inflate(R.layout.linear_layout, null);
if(i == 0){
iview.findViewById(R.id.imageView1).setBackgroundResource(R.drawable.distspeed);
}
if(i == 1){
iview.findViewById(R.id.imageView1).setBackgroundResource(R.drawable.hxmdist);
}
if(i == 2){
iview.findViewById(R.id.imageView1).setBackgroundResource(R.drawable.hxmspeeed);
}
iview.draw(canvas);
realViewSwitcher.addView(iview);
}
不適合我,但我找到了解決辦法,我必須創建自己的視圖,並且在onDraw過程中,我能夠繪製出路徑 – Csabi 2011-05-13 09:47:58