public ColorPanel(Point pt, ColorButton button) { colorButton = button; FormBorderStyle = FormBorderStyle.FixedDialog; MinimizeBox = false; MaximizeBox = false; ControlBox = false; ShowInTaskbar = false; TopMost = true; SetStyle(ControlStyles.DoubleBuffer, true); SetStyle(ControlStyles.UserPaint, true); SetStyle(ControlStyles.AllPaintingInWmPaint, true); Width = 156; Height = 100; if (colorButton.autoButton != "") { Height += 23; } if (colorButton.moreButton != "") { Height += 23; } CenterToScreen(); Location = pt; Capture = true; }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); Xamarin.Essentials.Platform.Init(this, savedInstanceState); // Set our view from the "main" layout resource SetContentView(Resource.Layout.activity_main); RelativeLayout relativeLayout = FindViewById <RelativeLayout>(Resource.Id.relativeLayout); ColorButton myColorButton = new ColorButton(this); myColorButton.Text = "My Color Button"; RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WrapContent, RelativeLayout.LayoutParams.WrapContent); layoutParams.AddRule(LayoutRules.RightOf, Resource.Id.colorbutton1); myColorButton.LayoutParameters = layoutParams; relativeLayout.AddView(myColorButton); }