【问题标题】:Is there a method like append() for Path in Android?Android中是否有类似append()的方法?
【发布时间】:2011-10-08 02:59:08
【问题描述】:

我有一行想要添加到路径中,但没有看到类似于 appened 的方法(在 Java 中将使用 GeneralPath.append(new Line2D.double))

例如,在 Java 代码中,我有类似的内容:

GeneralPath thePlots = new GeneralPath();
thePlots[CONST_INT].append(new Line2D.Double(centerX, centerY, xy[0], xy[1]), false);

//later I draw my line and whatever other points I have

但是,在 Android 中,我看不到附加选项(或 Line2D)。除了使用canvas.drawLine() 然后绘制其余点之外,还有其他方法吗?

【问题讨论】:

    标签: java android path append line


    【解决方案1】:

    你看过Path吗?

    【讨论】:

    • 这就是我所指的,有没有办法在 Path 中添加一行 :) - (我很高兴你一直愿意帮助 Android!)
    • 你可以path.moveTo设置初始位置,然后path.lineTo为你想添加的每一行。
    • 这就是我在之前的一个问题中所做的。我不确定它是否会跟踪初始位置。假设我在一个方法中创建了 Path 数组,但直到很久以后才绘制它,如果我使用 moveTo,它将跟踪整个路径?我的centerXcenterY 变量会变成什么?
    • 是的:见developer.android.com/reference/android/graphics/…。它将下一行的开头移动到新位置,但只要原始 Path 对象没有被重置,你应该没问题。严格来说它是一个路径,而不是一个路径数组:)
    猜你喜欢
    • 1970-01-01
    • 2018-02-25
    • 2013-06-07
    • 1970-01-01
    • 1970-01-01
    • 2012-11-22
    • 1970-01-01
    • 1970-01-01
    • 2016-07-29
    相关资源
    最近更新 更多