我尝试在 android 中绘制垂直线。
DrawView drawView;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
drawView = new DrawView(this);
setContentView(drawView);
}
public class DrawView extends View {
Paint paint = new Paint();
public DrawView(Context context) {
super(context);
paint.setColor(Color.RED);
}
@Override
public void onDraw(Canvas canvas) {
canvas.drawLine(0, 100, 0, 0, paint);
}
}
这仅画一条线。我想要在整个屏幕上绘制这条线。我怎样才能做到这一点?它必须在屏幕上垂直绘制。它现在垂直绘制,但只有一个。