Add user control

KirillRadchenkoKirillRadchenko RUMember ✭✭
edited June 2015 in Xamarin.Android

Hello.
I want to create ser control "MyChart". This control must contains many Images.

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">
    <MyChart
        android:id="@+id/MyChart"
        android:width="300"
        android:height="100"
        android:setY1="100"
        android:setY2="150" />
</LinearLayout>

[Activity(Label = "App1", MainLauncher = true, Icon = "@drawable/icon")]
    public class MainActivity : Activity
    {
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            SetContentView(Resource.Layout.Main);
    }
    }

public class MyChart:View
{
    public MyChart(){
    ImageView imageView = new ImageView(this);
    imageView.SetY(setY);
bitmap = Bitmap.CreateBitmap(width, height,Bitmap.Config.Argb8888);
Canvas canvas = new Canvas(bitmap);
    var paint = new Paint();
    paint.Color = Color.Red;
    paint.SetStyle(Paint.Style.Fill);

    Rect rect = new Rect(0, 0, width, height);
    canvas.DrawColor(Color.Transparent, PorterDuff.Mode.Clear);
    canvas.DrawRect(rect, paint);
imageView.SetImageBitmap(bitmap);
    }
}
Sign In or Register to comment.