bonjour à tous actuellment je dois faire un dessin sur une toile enfin bref sur une application mais je galère le tutoriel pour le dessin sur Androïd est en java voici mes fonctions avec une interface où je dois normalment dessiner ce que je veux
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
 
namespace TwoDDrawing
{
    public class myPathShape : View  , ISurfaceHolderCallback
    {
        ISurfaceHolder surfaceHolder;
        private ISurfaceHolder mHolder = null;
        private readonly ShapeDrawable _shape;
        Paint p;
        Bitmap b;
        Canvas c;
 
        public myPathShape(Context context): base(context)
        {
            var paint = new Paint();
            paint.SetARGB(255 , 200, 20, 0);
            paint.SetStyle(Paint.Style.Stroke);
            paint.StrokeWidth = 10;
            Path myPath = new Path();
            p = new Paint();
            p.SetStyle(Paint.Style.FillAndStroke);
            p.SetARGB(255, 120,110, 155);
            b = Bitmap.CreateBitmap(128, 128,Bitmap.Config.Argb8888);
            c = new Canvas(b);
           // myPath.AddRect(2, 4, 3, 5,Path.Direction.Ccw);
            //_shape = new ShapeDrawable(new PathShape(myPath,2,4));
          //  _shape.Paint.Set(paint);
 
           //_shape.SetBounds(0,0, 0, 0);
            c.DrawRect(new Rect(10,10,10,10) , p);
 
      }
 
 
 
        void ISurfaceHolderCallback.SurfaceChanged(ISurfaceHolder holder, Format format, int width, int height)
        {
            throw new NotImplementedException();
        }
 
        void ISurfaceHolderCallback.SurfaceCreated(ISurfaceHolder holder)
        {
            throw new NotImplementedException();
        }
 
        void ISurfaceHolderCallback.SurfaceDestroyed(ISurfaceHolder holder)
        {
            throw new NotImplementedException();
        }
 
        IntPtr IJavaObject.Handle
        {
            get { throw new NotImplementedException(); }
        }
 
        void IDisposable.Dispose()
        {
            throw new NotImplementedException();
        }
 
        public void init()
        {
 
        }
    }
 
}
et ma classe principal :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
 
using System;
 
using Android.App;
 
using Android.Content;
 
using Android.Runtime;
 
using Android.Views;
 
using Android.Widget;
 
using Android.OS;
 
 
 
namespace TwoDDrawing
 
{
 
    [Activity(Label = "TwoDDrawing", MainLauncher = true, Icon = "@drawable/icon")]
 
    public class MainActivity : Activity
 
    {
 
 
 
 
 
        protected override void OnCreate(Bundle bundle)
 
        {
 
            base.OnCreate(bundle);
 
 
 
            // Set our view from the "main" layout resource
 
 
 
 
 
            // Get our button from the layout resource,
 
            // and attach an event to it
 
 
 
        }
 
        public override bool OnTouchEvent(MotionEvent e)
 
        {  
 
 
 
 
 
            SetContentView(new myPathShape(this));
 
                        return base.OnTouchEvent(e);
 
        }
 
    }
 
}
je précise que je suis sous visual studio avec le framework xamarin , enfin bref comme vous pouvez le constater je fais nimp