I am not able add ScrollView to DrawView(Mycustom view). If I add scroll view it is not displaying draw view and the onDraw method is not executing.
My code is as follows. Can anyone help me solve the problem?
protected override void OnCreate (Bundle bundle)
{
ScrollView sc = new ScrollView (this);
DrawView drawView = new DrawView (this,10);
drawView.SetBackgroundColor(Color.White);
sc.AddView (drawView);
SetContentView (sc);
}
public class DrawView : View {
Paint paint = new Paint();
int count = 0;
public DrawView(Context context,int count):base(context) {
this.count = count;
paint.Color=Color.Black;
paint.StrokeWidth= 1;
}
public void drawlayout (Canvas canvas)
{
string Merdian = "AM";
canvas.DrawText (12 + " " + Merdian, 5, 20, paint);
for (int i = 0, j = 1; i < 24; i++, j++) {
Console.WriteLine ("hiii i enter the canvas");
canvas.DrawLine (50, 40 + (i * 40), this.Width, 40 + (i * 40), paint);
if (j == 12) {
Merdian = "PM";
canvas.DrawText (j + " " + Merdian, 5, 20 + ((i + 1) * 40), paint);
j = 0;
continue;
}
else
canvas.DrawText (j + " " + Merdian, 5, 20 + ((i + 1) * 40), paint);
}
paint.AntiAlias = true;
paint.StrokeWidth = 0.5f;
paint.Alpha = (0x80);
for (int i = 0; i <= 24; i++) {
canvas.DrawLine (50, 20 + (i * 40), this.Width, 20 + (i * 40), paint);
}
}
protected override void OnDraw(Canvas canvas) {
drawlayout (canvas);
Console.WriteLine ("in ondraw");
}
}
Thanks.
0 comments:
Post a Comment