Advertisement
Guest User

Untitled

a guest
Jul 2nd, 2015
212
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.83 KB | None | 0 0
  1. [Activity(Label = "SampleApp", Icon = "@drawable/icon", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation)]
  2. public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsApplicationActivity
  3. {
  4. App mainApp;
  5. protected override void OnCreate(Bundle bundle)
  6. {
  7. base.OnCreate(bundle);
  8.  
  9. global::Xamarin.Forms.Forms.Init(this, bundle);
  10. mainApp = new App();
  11. mainApp.ScreenWidth = (int)Resources.DisplayMetrics.WidthPixels;
  12. mainApp.ScreenHeight = (int)Resources.DisplayMetrics.HeightPixels;
  13. mainApp.LoadHomePage();
  14.  
  15.  
  16. LoadApplication(mainApp);
  17. }
  18.  
  19. public override void OnConfigurationChanged(Android.Content.Res.Configuration newConfig)
  20. {
  21. base.OnConfigurationChanged(newConfig);
  22.  
  23. mainApp.ScreenWidth = (int)Resources.DisplayMetrics.WidthPixels;
  24. mainApp.ScreenHeight = (int)Resources.DisplayMetrics.HeightPixels;
  25. mainApp.LoadHomePage();
  26. }
  27. }
  28.  
  29. int btnWidth = ScreenWidth / 5;
  30. StackLayout headerPaneLayout = new StackLayout();
  31. headerPaneLayout.Orientation = StackOrientation.Horizontal;
  32. headerPaneLayout.BackgroundColor = Color.Yellow;
  33. headerPaneLayout.Padding = new Thickness(0, 0, 0, 0);
  34. mainLayout.Children.Add(headerPaneLayout);
  35.  
  36. Button btn1 = new Button();
  37. btn1 .Text = "Take Survey";
  38. btn1 .WidthRequest = btnWidth;
  39. btn1 .HorizontalOptions = LayoutOptions.Start;
  40. headerPaneLayout.Children.Add(btn1 );
  41.  
  42. Button btn2 = new Button();
  43. btn2.Text = "PPE Product";
  44. btn2.WidthRequest = btnWidth;
  45. headerPaneLayout.Children.Add(btnPPEProduct);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement