请帮助我绘制如下图所示的形状。我已经尝试了很多东西,但是没有代码起作用。
这就是我尝试过的
private Point mFirstCurveStartPoint = new Point();
private Point mFirstCurveEndPoint = new Point();
.................................................
.................................................
mFirstCurveStartPoint.set((mNavigationBarWidth / 2) - (CURVE_CIRCLE_RADIUS * 2) - (CURVE_CIRCLE_RADIUS / 3), 0);
// the coordinates (x,y) of the end point after curve
mFirstCurveEndPoint.set(mNavigationBarWidth / 2, CURVE_CIRCLE_RADIUS + (CURVE_CIRCLE_RADIUS / 4));
mFirstCurveControlPoint1.set(mFirstCurveStartPoint.x + CURVE_CIRCLE_RADIUS + (CURVE_CIRCLE_RADIUS / 4), mFirstCurveStartPoint.y);
// the coordinates (x,y) of the 2nd control point on a cubic curve
mFirstCurveControlPoint2.set(mFirstCurveEndPoint.x - (CURVE_CIRCLE_RADIUS * 2) + CURVE_CIRCLE_RADIUS, mFirstCurveEndPoint.y);
mPath.reset();
mPath.moveTo(0, 0);
mPath.lineTo(mFirstCurveStartPoint.x, mFirstCurveStartPoint.y);
mPath.cubicTo(mFirstCurveControlPoint1.x, mFirstCurveControlPoint1.y,
mFirstCurveControlPoint2.x, mFirstCurveControlPoint2.y,
mFirstCurveEndPoint.x, mFirstCurveEndPoint.y);
有什么办法可以使用Xml布局做到这一点
最佳答案
如果您有svg格式的图像,请使用Asset Studio将其转换为xml drawable。否则,使用如下代码:
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="500dp"
android:height="300dp"
android:viewportWidth="500"
android:viewportHeight="300">
<path
android:pathData="M0,0h500v300h-500z"
android:fillColor="#e3e3e3"/>
<path
android:pathData="M0,80C0,250 487,104 550,247L500,300L0,300"
android:fillColor="#3e47cb"/>
</vector>
关于java - 如何绘制如下图所示的形状,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/56558655/