c# - How do you make buttons programmatically using xamarin? -


i'm trying create buttons programmatically using xamarin ide (c#). code need create button, set size, set text, set background color, , set constraints? there way define button 1/4 of width of screen? in advance.

first create button

uibutton button = new uibutton();  cgrect screenbounds = uiscreen.mainscreen.bounds; float buttonwidth = (float)screenbounds.x / 4; button.frame = new cgrect (0f, 0f, buttonwidth, 50f);  button.settitle ("title", uicontrolstate.normal); button.backgroundcolor = uicolor.green; 

and add subview active view

this.addsubview (button); 

and add event touchupinside

button.touchupinside += (object sender, system.eventargs e) => {    debug.writeline( "button clicked!"); }; 

Comments

Popular posts from this blog

OpenCV OpenCL: Convert Mat to Bitmap in JNI Layer for Android -

android - org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope -

python - How to remove the Xframe Options header in django? -