[英]How to draw shape like below image
Please help me to draw a shape like the image below. 请帮我画出如下图所示的形状。 I have tried many things, but none of the code worked.
我尝试了很多东西,但没有一个代码有效。
This is what I have tried 这就是我尝试过的
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);
is there any way to done this using Xml layout 有没有办法使用Xml布局完成此操作
If you have an image in svg format, use Asset Studio to convert it to xml drawable. 如果您有svg格式的图像,请使用Asset Studio将其转换为xml drawable。 Otherwise, use code like that:
否则,使用这样的代码:
<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>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.