Hi, I need to draw a track in simple lines on a canvas so that it draws out a red rectangle with white lines. But he does not emit anything that I miss. my code is:
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); }
android
Csabi
source share