Bitmap bitmap = Bitmap.createBitmap(ToolUtils.dip2px(423), ToolUtils.dip2px(168), Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(bitmap); Path path = new Path(); //多边形的起点 path.moveTo(ToolUtils.dip2px(35) + percent * (width -ToolUtils.dip2px(45)), 0); //lineto的坐标是绝对坐标,相对(0,0) path.lineTo(percent * (width + ToolUtils.dip2px(25)), height); path.lineTo(width, height); path.lineTo(width,0); path.close(); canvas.drawPath(path, paint);
vector画图 <vector xmlns:android="http://schemas.android.com/apk/res/android" android:width="32dp" android:height="26dp" android:viewportWidth="32" android:viewportHeight="26"> <path android:fillColor="@color/white" android:pathData="M16,0l-16,26 32,0z" />//m起点,l是相对的起一个点的坐标 </vector>