2
嗨,我想繪製路徑到畫布中,但它沒有做任何事情,它也不繪製畫布。
我的代碼:如何在android中繪製路徑到畫布中?
Path path = new Path();
Canvas canvas = new Canvas();
Paint paint = new Paint();
paint.setColor(Color.BLACK);
canvas.drawColor(Color.CYAN);
for (int i = 5; i < 50; i++)
{
path.setLastPoint(4, i - 1);
path.lineTo(4, i);
}
path.close();
for (int i = 0; i < 5; i++)
{
View iview = inflater.inflate(R.layout.linear_layout, null);
iview.findViewById(R.id.imageView1);//.setBackgroundColor(backgroundColors[i]);
ShapeDrawable mDrawable = new ShapeDrawable(new OvalShape());
mDrawable.getPaint().setColor(Color.YELLOW);
mDrawable.setBounds(10, 10, 15, 15);
canvas.drawPath(path, paint);
mDrawable.draw(canvas);
iview.draw(canvas);
realViewSwitcher.addView(iview);
}
它表明我只綠色這是view.backroundColor
的默認值。
感謝