Android 绘图(一)——绘制直线的drawnline方法

  功能: 此方法用于画布上绘制直线,通过制定两个端点的坐标进行绘制,这只能绘制单条直线,绘制多条是drawlines方法。

【基本语法】public void drawLine (float startX, float startY, float stopX, float stopY, Paint paint)

参数说明

startX:起始端点的X坐标。

startY:起始端点的Y坐标。

stopX:终止端点的X坐标。

stopY:终止端点的Y坐标。

paint:绘制直线所使用的画笔。

源码分析:

/**
     *
Draw a line segment with the specified start and stop x,y coordinates,
     * using the specified paint.//使用指定的画笔,画一条指定好起止x,y坐标的线段
     * <p>Note that since a line is always "framed", the Style is ignored in the paint.</p>//注意:因为线的样式已经定义了,风格在画笔中是被忽略的
* <p>Degenerate lines (length is 0) will not be drawn.</p>//简并线(长度为0)将不会被画出来
     * @param startX The x-coordinate of the start point of the line//开始的X坐标点
     * @param startY The y-coordinate of the start point of the line//开始的Y坐标点
     * @param paint  The paint used to draw the line//画线的画笔
     */
    public void drawLine(float startX, float startY, float stopX, float stopY, Paint paint) {
        native_drawLine(mNativeCanvas, startX, startY, stopX, stopY, paint.mNativePaint);
    }

例子1

1
2
3
4
5
6
  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值