private void CheckboxPropertyChanged(ElementsLaboratory.Controls.CheckBox model, String propertyName) { if (propertyName == null || ElementsLaboratory.Controls.CheckBox.IsCheckedProperty.PropertyName == propertyName) { checkBox.Checked = model.IsChecked; } if (propertyName == null || ElementsLaboratory.Controls.CheckBox.ColorProperty.PropertyName == propertyName) { int[][] states = { new int[] { Android.Resource.Attribute.StateEnabled }, // enabled new int[] { Android.Resource.Attribute.StateEnabled }, // disabled new int[] { Android.Resource.Attribute.StateChecked }, // unchecked new int[] { Android.Resource.Attribute.StatePressed } // pressed }; var checkBoxColor = (int)model.Color.ToAndroid(); int[] colors = { checkBoxColor, checkBoxColor, checkBoxColor, checkBoxColor }; var myList = new Android.Content.Res.ColorStateList(states, colors); // Border color of default XEntry. if (Build.VERSION.SdkInt >= BuildVersionCodes.Lollipop) { checkBox.ButtonTintList = myList; } } }
private void CheckboxPropertyChanged(Checkbox model, String propertyName) { if (propertyName == null || Checkbox.IsCheckedProperty.PropertyName == propertyName) { checkBox.Checked = model.IsChecked; //checkBox.ButtonDrawable.SetTint(Color.Blue.ToAndroid()); } if (propertyName == null || Checkbox.ColorProperty.PropertyName == propertyName) { int[][] states = { new int[] { Android.Resource.Attribute.StateEnabled }, // enabled new int[] { Android.Resource.Attribute.StateEnabled }, // disabled new int[] { Android.Resource.Attribute.StateChecked }, // unchecked new int[] { Android.Resource.Attribute.StatePressed } // pressed }; var checkBoxColor = (int)model.Color.ToAndroid(); int[] colors = { checkBoxColor, checkBoxColor, checkBoxColor, checkBoxColor }; var myList = new Android.Content.Res.ColorStateList(states, colors); checkBox.ButtonTintList = myList; } }
private void CustomizeTabs() { var stateList = new Android.Content.Res.ColorStateList( new int[][] { new int[] { Android.Resource.Attribute.StateChecked }, new int[] { Android.Resource.Attribute.StateEnabled } }, new int[] { Color.Gray, //Selected Color.Black //Normal }); // BottomTabbedRenderer.BackgroundColor = new Android.Graphics.Color(23, 31, 50); BottomTabbedRenderer.FontSize = 10; BottomTabbedRenderer.IconSize = 36; // BottomTabbedRenderer.ItemTextColor = stateList; BottomTabbedRenderer.ItemIconTintList = stateList; // BottomTabbedRenderer.Typeface = Typeface.CreateFromAsset(this.Assets, "HiraginoKakugoProNW3.otf"); // BottomTabbedRenderer.ItemBackgroundResource = Resource.Drawable.bnv_selector; BottomTabbedRenderer.ItemSpacing = 5; BottomTabbedRenderer.ItemPadding = new Xamarin.Forms.Thickness(0, 30, 0, 0); BottomTabbedRenderer.BottomBarHeight = 50; BottomTabbedRenderer.ItemAlign = ItemAlignFlags.Center; }
public void SetUpBottomBar() { var stateList = new Android.Content.Res.ColorStateList( new int[][] { new int[] { Android.Resource.Attribute.StateChecked }, new int[] { Android.Resource.Attribute.StateEnabled } }, new int[] { Android.Graphics.Color.Rgb(73, 132, 232), //Selected Android.Graphics.Color.Rgb(123, 123, 123) //Normal }); BottomTabbedRenderer.VisibleTitle = true; BottomTabbedRenderer.BackgroundColor = new Android.Graphics.Color(255, 255, 255); BottomTabbedRenderer.FontSize = 11; BottomTabbedRenderer.IconSize = 30; BottomTabbedRenderer.ItemTextColor = stateList; BottomTabbedRenderer.ItemIconTintList = stateList; BottomTabbedRenderer.Typeface = Typeface.SansSerif; BottomTabbedRenderer.ItemSpacing = 4; //BottomTabbedRenderer.ItemPadding = new Xamarin.Forms.Thickness(6); BottomTabbedRenderer.BottomBarHeight = 0; //60 BottomTabbedRenderer.ItemAlign = ItemAlignFlags.Center; }
public static Drawable CreateItemBackgroundDrawable() { var stateList = ColorStateList.ValueOf(Colors.Black.MultiplyAlpha(0.2f).ToNative()); var colorDrawable = new ColorDrawable(AColor.White); return(new RippleDrawable(stateList, colorDrawable, null)); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.activity_main); FloatingActionButton fab = FindViewById <FloatingActionButton>(Resource.Id.fab); fab.Click += FabOnClick; FloatingActionButton fabReport = FindViewById <FloatingActionButton>(Resource.Id.fabReport); fabReport.Click += FabReportOnClick; Android.Content.Res.ColorStateList csl = new Android.Content.Res.ColorStateList(new int[][] { new int[0] }, new int[] { Android.Graphics.Color.ParseColor("#c62828") }); fabReport.BackgroundTintList = csl; BottomNavigationView navigation = FindViewById <BottomNavigationView>(Resource.Id.navigation); navigation.SetOnNavigationItemSelectedListener(this); ft = FragmentManager.BeginTransaction(); ft.SetCustomAnimations(Resource.Animator.enter_from_left, Resource.Animator.exit_to_right); ft.AddToBackStack(null); ft.Add(Resource.Id.FrameLayout, new MapsFragment()); ft.Commit(); }
void SetupBottomTabs() { var stateList = new Android.Content.Res.ColorStateList( new int[][] { new int[] { Android.Resource.Attribute.StateChecked }, new int[] { Android.Resource.Attribute.StateEnabled } }, new int[] { Color.Red, //Selected Color.Gray //Normal }); BottomTabbedRenderer.VisibleTitle = true; //BottomTabbedRenderer.BackgroundColor = new Color(0x9C, 0x27, 0xB0); BottomTabbedRenderer.BackgroundColor = new Color(255, 255, 255); BottomTabbedRenderer.FontSize = 13f; BottomTabbedRenderer.IconSize = 24; BottomTabbedRenderer.ItemTextColor = stateList; BottomTabbedRenderer.ItemIconTintList = stateList; BottomTabbedRenderer.Typeface = Typeface.CreateFromAsset(this.Assets, "HelveticaNeue.ttf"); BottomTabbedRenderer.ItemBackgroundResource = Resource.Drawable.abc_list_selector_background_transition_holo_light; BottomTabbedRenderer.ItemSpacing = 4; BottomTabbedRenderer.ItemPadding = new Xamarin.Forms.Thickness(6); BottomTabbedRenderer.BottomBarHeight = 56; BottomTabbedRenderer.ItemAlign = ItemAlignFlags.Center; BottomTabbedRenderer.MenuItemIconSetter = (menuItem, iconSource, selected) => { var resId = Resources.GetIdentifier(iconSource.File, "drawable", PackageName); switch (iconSource.File) { case "ic_audiotrack_black_24dp": menuItem.SetIcon(Resource.Drawable.u81); break; case "ic_backup_black_24dp": menuItem.SetIcon(Resource.Drawable.u75); break; case "ic_camera_black_24dp": menuItem.SetIcon(Resource.Drawable.u143); break; case "ic_favorite_black_24dp": menuItem.SetIcon(Resource.Drawable.More); break; case "ic_audiotrack_black_25dp": menuItem.SetIcon(Resource.Drawable.report); break; case "ic_camera_black_26dp": menuItem.SetIcon(Resource.Drawable.Contact); break; default: menuItem.SetIcon(resId); break; } }; }
protected override void OnCreate(Bundle bundle) { TabLayoutResource = Resource.Layout.Tabbar; ToolbarResource = Resource.Layout.Toolbar; var stateList = new Android.Content.Res.ColorStateList( new int[][] { new int[] { Android.Resource.Attribute.StateChecked }, new int[] { Android.Resource.Attribute.StateEnabled } }, new int[] { new Android.Graphics.Color(67, 163, 245), //Selected new Android.Graphics.Color(187, 188, 190) //Normal }); BottomTabbedRenderer.BackgroundColor = new Android.Graphics.Color(23, 31, 50); BottomTabbedRenderer.FontSize = 10; BottomTabbedRenderer.IconSize = 20; BottomTabbedRenderer.ItemTextColor = stateList; BottomTabbedRenderer.ItemIconTintList = stateList; BottomTabbedRenderer.Typeface = Typeface.CreateFromAsset(this.Assets, "HiraginoKakugoProNW3.otf"); BottomTabbedRenderer.ItemBackgroundResource = Resource.Drawable.bnv_selector; base.OnCreate(bundle); global::Xamarin.Forms.Forms.Init(this, bundle); LoadApplication(new Demo.App()); }
public Android.Content.Res.ColorStateList GetTextColors() { int[] colors = new int[] { 0xf38f5c, 0x553727, 0x553727 }; int[][] states = new int[3][]; states[0] = new int[] { Android.Resource.Attribute.StateEnabled }; states[1] = new int[] { Android.Resource.Attribute.StateEnabled, Android.Resource.Attribute.StatePressed, Android.Resource.Attribute.StateFocused }; states[2] = new int[] { Android.Resource.Attribute.StateEnabled, Android.Resource.Attribute.StatePressed }; Android.Content.Res.ColorStateList colorList = new Android.Content.Res.ColorStateList(states, colors); return(colorList); }
public ResultListAdapter(Activity context, float textWeight, int textResId, bool showCheckBox) { _context = context; _items = new List<TableResultItem> (); _textWeight = textWeight; _textResId = textResId; _showCheckBox = showCheckBox; TextView dummy = new TextView(context); _defaultTextColors = dummy.TextColors; }
public static void SetItemIconTintList(BindableObject view, string value) { List <int> colorList = StringToColorStateList(value); var resource = new Android.Content.Res.ColorStateList( new int[][] { new int[] { Android.Resource.Attribute.StateChecked }, new int[] { Android.Resource.Attribute.StateEnabled } }, colorList.ToArray()); view.SetValue(ItemIconTintListProperty, resource); }
public static Drawable CreateItemBackgroundDrawable() { var stateList = ColorStateList.ValueOf(Color.Black.MultiplyAlpha(0.2).ToAndroid()); var colorDrawable = new ColorDrawable(AColor.White); if (Forms.IsLollipopOrNewer) { return(new RippleDrawable(stateList, colorDrawable, null)); } return(colorDrawable); }
void SetupBottomTabs() { var stateList = new Android.Content.Res.ColorStateList( new int[][] { new int[] { Android.Resource.Attribute.StateChecked }, new int[] { Android.Resource.Attribute.StateEnabled } }, new int[] { //Color.Red, //Selected //Color.White //Normal Color.White, //Selected Color.LightGray //Normal }); //BottomTabbedRenderer.BackgroundColor = new Color(0x9C, 0x27, 0xB0); BottomTabbedRenderer.BackgroundColor = new Color(0x21, 0x96, 0xF3); //BottomTabbedRenderer.FontSize = 12f; BottomTabbedRenderer.FontSize = 14f; BottomTabbedRenderer.IconSize = 16; BottomTabbedRenderer.ItemTextColor = stateList; BottomTabbedRenderer.ItemIconTintList = stateList; //BottomTabbedRenderer.Typeface = Typeface.CreateFromAsset(this.Assets, "architep.ttf"); //BottomTabbedRenderer.Typeface = Typeface.CreateFromAsset(this.Assets, "HiraginoKakugoProNW3.otf"); BottomTabbedRenderer.ItemBackgroundResource = Resource.Drawable.bnv_selector; BottomTabbedRenderer.ItemSpacing = 4; //BottomTabbedRenderer.ItemPadding = new Xamarin.Forms.Thickness(6); BottomTabbedRenderer.BottomBarHeight = 56; BottomTabbedRenderer.ItemAlign = ItemAlignFlags.Center; BottomTabbedRenderer.ShouldUpdateSelectedIcon = true; BottomTabbedRenderer.MenuItemIconSetter = (menuItem, iconSource, selected) => { var iconized = Iconize.FindIconForKey(iconSource.File); if (iconized == null) { BottomTabbedRenderer.DefaultMenuItemIconSetter.Invoke(menuItem, iconSource, selected); return; } //var drawable = new IconDrawable(this, iconized).Color(selected ? Color.Red : Color.White).SizeDp(30); var drawable = new IconDrawable(this, iconized).Color(selected ? Color.White : Color.LightGray).SizeDp(30); menuItem.SetIcon(drawable); }; }
protected override void OnElementChanged(ElementChangedEventArgs <Xamarin.Forms.TabbedPage> e) { base.OnElementChanged(e); if (e.OldElement == null && e.NewElement != null) { for (int i = 0; i <= this.ViewGroup.ChildCount - 1; i++) { var childView = this.ViewGroup.GetChildAt(i); if (childView is ViewGroup viewGroup) { ((ViewGroup)childView).SetClipChildren(false); for (int j = 0; j <= viewGroup.ChildCount - 1; j++) { var childRelativeLayoutView = viewGroup.GetChildAt(j); if (childRelativeLayoutView is BottomNavigationView bottomView) { FloatingActionButton button = new FloatingActionButton(context); BottomNavigationView.LayoutParams parameters = new BottomNavigationView.LayoutParams(200, 200); string myString = "f029"; var chars = new char[] { (char)Convert.ToInt32(myString, 16) }; string iconKey = new string(chars); DrawableAwesome drable = new DrawableAwesome.DrawableAwesomeBuilder(context, iconKey).SetSize(50).build(); button.SetImageDrawable(drable); button.SetImageDrawable(Resources.GetDrawable(Resource.Drawable.scan)); parameters.Gravity = GravityFlags.Center; Android.Content.Res.ColorStateList csl = new Android.Content.Res.ColorStateList(new int[][] { new int[0] }, new int[] { Android.Graphics.Color.ParseColor("#3891D6") }); button.BackgroundTintList = csl; button.SetScaleType(ImageView.ScaleType.Center); button.SetScaleType(ImageView.ScaleType.FitCenter); //button.cu = 60; parameters.BottomMargin = 40; button.LayoutParameters = parameters; //button.sc button.Click += Button_Click; bottomView.AddView(button); } } } } } }
static void OnItemIconTintListChanged(BindableObject view, object oldValue, object newValue) { var tabbedPage = view as TabbedPage; if (tabbedPage == null) { return; } if (newValue != null && oldValue != newValue) { var colorList = StringToColorStateList(newValue as string); var resource = new Android.Content.Res.ColorStateList( new int[][] { new int[] { Android.Resource.Attribute.StateChecked }, new int[] { Android.Resource.Attribute.StateEnabled } }, colorList.ToArray()); BottomTabbedRenderer.ItemIconTintList = resource; } }
private void SetupBottomTabs() { var stateList = new Android.Content.Res.ColorStateList( new int[][] { new int[] { Android.Resource.Attribute.StateChecked }, new int[] { Android.Resource.Attribute.StateEnabled } }, new int[] { Android.Graphics.Color.ParseColor("#7fadf7"), //Selected Android.Graphics.Color.ParseColor("#9b9797") //Normal }); //new Color(Resource.Color.colorPrimary) //Normal //{StaticResource Primary} //new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FFD2D2D2")); //System.Drawing.Color sdColor2 = Xamarin.Forms.Color.FromHex("FF6A00"); BottomTabbedRenderer.BackgroundColor = Android.Graphics.Color.ParseColor("#e5e0e0"); BottomTabbedRenderer.FontSize = 11f; BottomTabbedRenderer.IconSize = 16; BottomTabbedRenderer.ItemTextColor = stateList; BottomTabbedRenderer.ItemIconTintList = stateList; BottomTabbedRenderer.Typeface = Typeface.CreateFromAsset(this.Assets, "iconize-fontawesome.ttf"); //BottomTabbedRenderer.ItemBackgroundResource = Resource.Drawable.bnv_selector; BottomTabbedRenderer.ItemSpacing = 2; //BottomTabbedRenderer.ItemPadding = new Xamarin.Forms.Thickness(6); BottomTabbedRenderer.BottomBarHeight = 50; BottomTabbedRenderer.ItemAlign = ItemAlignFlags.Center; BottomTabbedRenderer.ShouldUpdateSelectedIcon = true; BottomTabbedRenderer.MenuItemIconSetter = (menuItem, iconSource, selected) => { var iconized = Iconize.FindIconForKey(iconSource.File); if (iconized == null) { BottomTabbedRenderer.DefaultMenuItemIconSetter.Invoke(menuItem, iconSource, selected); return; } var drawable = new IconDrawable(this, iconized).Color(selected ? Android.Graphics.Color.ParseColor("#7fadf7") : Android.Graphics.Color.ParseColor("#9b9797")).SizeDp(30); menuItem.SetIcon(drawable); }; }
private static void CustomizeTab() { var stateList = new Android.Content.Res.ColorStateList( new int[][] { new int[] { Android.Resource.Attribute.StateChecked }, new int[] { Android.Resource.Attribute.StateEnabled }, }, new int[] { new Android.Graphics.Color(253, 217, 169), new Android.Graphics.Color(11, 4, 1) }); BottomTabbedRenderer.FontSize = 10; BottomTabbedRenderer.IconSize = 20; BottomTabbedRenderer.ItemSpacing = 8; BottomTabbedRenderer.ItemPadding = new Xamarin.Forms.Thickness(8); BottomTabbedRenderer.BottomBarHeight = 50; BottomTabbedRenderer.BackgroundColor = new Android.Graphics.Color(58, 38, 30); BottomTabbedRenderer.ItemTextColor = stateList; BottomTabbedRenderer.ItemIconTintList = stateList; }
void SetupBottomTabs() { var stateList = new Android.Content.Res.ColorStateList( new int[][] { new int[] { Android.Resource.Attribute.StateChecked }, new int[] { Android.Resource.Attribute.StateEnabled } }, new int[] { new Color(67, 163, 245), //Selected new Color(187, 188, 190) //Normal }); BottomTabbedRenderer.BackgroundColor = new Color(23, 31, 50); BottomTabbedRenderer.FontSize = 12.5f; BottomTabbedRenderer.IconSize = 16; BottomTabbedRenderer.ItemTextColor = stateList; BottomTabbedRenderer.ItemIconTintList = stateList; BottomTabbedRenderer.Typeface = Typeface.CreateFromAsset(this.Assets, "architep.ttf"); BottomTabbedRenderer.ItemBackgroundResource = Resource.Drawable.bnv_selector; BottomTabbedRenderer.ItemSpacing = 24; BottomTabbedRenderer.ItemPadding = new Xamarin.Forms.Thickness(12); BottomTabbedRenderer.BottomBarHeight = 160; BottomTabbedRenderer.ItemAlign = ItemAlignFlags.Top; BottomTabbedRenderer.MenuItemIconSetter = (menuItem, iconSource) => { var iconized = Iconize.FindIconForKey(iconSource.File); if (iconized == null) { BottomTabbedRenderer.DefaultMenuItemIconSetter.Invoke(menuItem, iconSource); return; } var drawable = new IconDrawable(this, iconized).Color(Color.White).SizeDp(20); menuItem.SetIcon(drawable); }; }
void SetupBottomTabs() { var stateList = new Android.Content.Res.ColorStateList( new int[][] { new int[] { Android.Resource.Attribute.StateChecked }, new int[] { Android.Resource.Attribute.StateEnabled } }, new int[] { Color.DarkGray, //Selected Color.LightGray //Normal }); BottomTabbedRenderer.BackgroundColor = Color.WhiteSmoke; BottomTabbedRenderer.FontSize = 12f; BottomTabbedRenderer.IconSize = 16; BottomTabbedRenderer.ItemTextColor = stateList; BottomTabbedRenderer.ItemIconTintList = stateList; BottomTabbedRenderer.ItemSpacing = 4; BottomTabbedRenderer.ItemPadding = new Xamarin.Forms.Thickness(6); BottomTabbedRenderer.BottomBarHeight = 56; BottomTabbedRenderer.ItemAlign = ItemAlignFlags.Center; BottomTabbedRenderer.MenuItemIconSetter = (menuItem, iconSource, selected) => { if (menuItem.TitleFormatted.ToString() == "Accounts") { menuItem.SetIcon(Resource.Drawable.ic_accounts_black); } else if (menuItem.TitleFormatted.ToString() == "Statistics") { menuItem.SetIcon(Resource.Drawable.ic_statistics_black); } else if (menuItem.TitleFormatted.ToString() == "Settings") { menuItem.SetIcon(Resource.Drawable.ic_settings_black); } }; }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); str_Imei = getImeiValue(); deviceXMLToBase64String = getDeviceXMLToBase64(); loginXMLToBase64String = getLoginXMLToBase64(); FloatingActionButton fab = FindViewById <FloatingActionButton>(Resource.Id.fab1); Android.Content.Res.ColorStateList csl = new Android.Content.Res.ColorStateList(new int[][] { new int[0] }, new int[] { Android.Graphics.Color.ParseColor("#999999") }); fab.BackgroundTintList = csl; layout = FindViewById <LinearLayout>(Resource.Id.login_content_frame); layout.SetOnTouchListener(this); username_edit = FindViewById <EditText>(Resource.Id.username); password_edit = FindViewById <EditText>(Resource.Id.password); depot_edit = FindViewById <EditText>(Resource.Id.depot); round_edit = FindViewById <EditText>(Resource.Id.round); var bindingSet = this.CreateBindingSet <LoginView, LoginViewModel>(); bindingSet.Bind().For(c => c.Username).To(vm => vm.Username); bindingSet.Bind().For(c => c.IsLoading).To(vm => vm.IsLoading); bindingSet.Bind().For(c => c.Baduser_error).To(vm => vm.Baduser_error); bindingSet.Bind().For(c => c.Session_exist).To(vm => vm.Session_exist); bindingSet.Bind().For(c => c.Other_error).To(vm => vm.Other_error); bindingSet.Bind().For(c => c.Login_success).To(vm => vm.Login_success); bindingSet.Bind().For(c => c.Depot_status).To(vm => vm.Depot_status); bindingSet.Bind().For(c => c.Starting_round).To(vm => vm.Starting_round); bindingSet.Bind().For(c => c.Invalid_round).To(vm => vm.Invalid_round); bindingSet.Bind().For(c => c.Timeout).To(vm => vm.Timeout); bindingSet.Bind().For(c => c.Connection).To(vm => vm.Connection); bindingSet.Apply(); }
protected override void OnElementChanged(ElementChangedEventArgs <Xamarin.Forms.Switch> e) { base.OnElementChanged(e); if (e.OldElement != null || e.NewElement == null) { return; } view = (ModeSwitch)Element; if (Build.VERSION.SdkInt >= BuildVersionCodes.JellyBean) { if (Control != null) { int[][] states = new int[][] { new int[] { Android.Resource.Attribute.StateEnabled }, // enabled new int[] { -Android.Resource.Attribute.StateEnabled }, // disabled }; var backgroundColorsList = new Android.Content.Res.ColorStateList(states, new int[] { view.BackgroundTintColor.ToAndroid(), view.BackgroundTintColor.WithLuminosity(.9).ToAndroid() }); var thumbColorsList = new Android.Content.Res.ColorStateList(states, new int[] { view.ThumbTintColor.ToAndroid(), view.ThumbTintColor.WithSaturation(.4).WithLuminosity(.8).ToAndroid() }); //var thumbColor = view.ThumbTintColor.ToAndroidPreserveDisabled(thumbColorsList); Control.TrackTintList = backgroundColorsList; Control.ThumbTintList = thumbColorsList; } } }
void SetupBottomTabs() { var stateList = new Android.Content.Res.ColorStateList( new int[][] { new int[] { Android.Resource.Attribute.StateChecked }, new int[] { Android.Resource.Attribute.StateEnabled } }, new int[] { new Color(67, 163, 245), //Selected new Color(187, 188, 190) //Normal }); BottomTabbedRenderer.BackgroundColor = new Color(23, 31, 50); BottomTabbedRenderer.FontSize = 12.5f; BottomTabbedRenderer.IconSize = 16; BottomTabbedRenderer.ItemTextColor = stateList; BottomTabbedRenderer.ItemIconTintList = stateList; BottomTabbedRenderer.Typeface = Typeface.CreateFromAsset(this.Assets, "architep.ttf"); BottomTabbedRenderer.ItemBackgroundResource = Resource.Drawable.bnv_selector; BottomTabbedRenderer.ItemSpacing = 24; BottomTabbedRenderer.ItemPadding = new Xamarin.Forms.Thickness(12); BottomTabbedRenderer.BottomBarHeight = 160; BottomTabbedRenderer.ItemAlign = ItemAlignFlags.Top; }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); // Set our view from the "main" layout resource SetContentView(Resource.Layout.Main); //Layouts LinearLayout layoutbase = FindViewById <LinearLayout>(Resource.Id.mainLinear); layoutbase.SetBackgroundColor(Color.DarkRed); RelativeLayout relativebase = new RelativeLayout(this); relativebase.SetBackgroundColor(Color.Transparent); //Gets the actual phones dimensions var met = Resources.DisplayMetrics; scrW = met.WidthPixels; scrH = met.HeightPixels; //New colors Color tBlack = new Color(0, 0, 0, 80); Color etxtHintColor = new Color(56, 56, 56); Color etxtFontColor = Color.Silver; //Color state list Android.Content.Res.ColorStateList cslRG = new Android.Content.Res.ColorStateList( new int[][] { new int[] { -Android.Resource.Attribute.StateEnabled }, new int[] { Android.Resource.Attribute.StateEnabled } }, new int[] { tBlack, Color.Silver }); //Item creations etxtDiff = new EditText(this) { InputType = Android.Text.InputTypes.ClassNumber, Hint = GetString(Resource.String.difficulty), Gravity = GravityFlags.Center }; etxtDiff.SetHintTextColor(etxtHintColor); etxtDiff.SetTextColor(etxtFontColor); etxtRoll = new EditText(this) { InputType = Android.Text.InputTypes.ClassNumber, Hint = GetString(Resource.String.roll), Gravity = GravityFlags.Center }; etxtRoll.SetHintTextColor(etxtHintColor); etxtRoll.SetTextColor(etxtFontColor); txtVResult = new TextView(this) { TextAlignment = TextAlignment.Gravity, Gravity = GravityFlags.Center, TextSize = 20, Text = Calculate(etxtDiff.Text, etxtRoll.Text), Id = Resource.String.idtxtResult }; txtVResult.SetTextColor(Color.Black); TextView txtDiff = new TextView(this) { Id = 99, Gravity = GravityFlags.Left, TextSize = 18, Text = GetString(Resource.String.diff_text) }; txtDiff.SetTextColor(Color.Black); ddlDiff = new Spinner(this) { Id = 98 }; //Radio group rgShooting1 = new RadioGroup(this) { Orientation = Orientation.Horizontal }; RadioButton[] rb1 = new RadioButton[3]; for (int i = 0; i < rb1.Length; i++) { rb1[i] = new RadioButton(this) { Text = GetString(GetShootingID(i)), Id = 100 + i, ButtonTintList = cslRG }; rb1[i].SetTextColor(Color.Goldenrod); rb1[i].Click += RBRangeDeselect_Click; rgShooting1.AddView(rb1[i]); } rgShooting2 = new RadioGroup(this) { Orientation = Orientation.Horizontal }; RadioButton[] rb2 = new RadioButton[2]; for (int i = 0; i < rb2.Length; i++) { rb2[i] = new RadioButton(this) { Text = GetString(GetShootingID(i + 3)), Id = 103 + i, ButtonTintList = cslRG }; rb2[i].SetTextColor(Color.Goldenrod); rb2[i].Click += RBRangeDeselect_Click; rgShooting2.AddView(rb2[i]); } rgShooting1.ClearCheck(); rgShooting2.ClearCheck(); rgShootMode = new RadioGroup(this) { Orientation = Orientation.Horizontal }; RadioButton[] rbMode = new RadioButton[3]; for (int i = 0; i < rbMode.Length; i++) { rbMode[i] = new RadioButton(this) { Text = GetString(GetShotModeId(i)), Id = 200 + i, Gravity = GravityFlags.Center, ButtonTintList = cslRG }; rbMode[i].SetTextColor(Color.Goldenrod); rgShootMode.AddView(rbMode[i]); } rgShootMode.ClearCheck(); //Create layouts LinearLayout.LayoutParams llpMW = new LinearLayout.LayoutParams(LayoutParams.MatchParent, LayoutParams.WrapContent); LinearLayout.LayoutParams llpMWBM40 = new LinearLayout.LayoutParams(LayoutParams.MatchParent, LayoutParams.WrapContent) { BottomMargin = 40 }; LinearLayout.LayoutParams llpMWBM80 = new LinearLayout.LayoutParams(LayoutParams.MatchParent, LayoutParams.WrapContent) { BottomMargin = 80 }; LinearLayout.LayoutParams llpTxtDiff = new LinearLayout.LayoutParams(MathCeiling(scrW, 0.4), LayoutParams.WrapContent) { BottomMargin = 40, Gravity = GravityFlags.Left }; LinearLayout.LayoutParams llpDdlDiff = new LinearLayout.LayoutParams(MathCeiling(scrW, 0.44), LayoutParams.WrapContent) { BottomMargin = 40, Gravity = GravityFlags.Right }; LinearLayout.LayoutParams llpWWC = new LinearLayout.LayoutParams(LayoutParams.WrapContent, LayoutParams.WrapContent) { Gravity = GravityFlags.Center }; RelativeLayout.LayoutParams rlpRlo = new RelativeLayout.LayoutParams(scrW, scrH); RelativeLayout.LayoutParams rlpTxtDiff = new RelativeLayout.LayoutParams(MathCeiling(scrW, 0.4), LayoutParams.WrapContent) { LeftMargin = MathCeiling(scrW, 0.1), TopMargin = 20, BottomMargin = 40 }; rlpTxtDiff.AddRule(LayoutRules.AlignParentLeft); RelativeLayout.LayoutParams rlpDdlDiff = new RelativeLayout.LayoutParams(MathCeiling(scrW, 0.44), LayoutParams.WrapContent) { TopMargin = 20, BottomMargin = 40 }; rlpDdlDiff.AddRule(LayoutRules.AlignParentRight); //Add layouts etxtDiff.LayoutParameters = llpMW; ddlDiff.LayoutParameters = rlpDdlDiff; txtDiff.LayoutParameters = rlpTxtDiff; etxtRoll.LayoutParameters = llpMWBM40; txtVResult.LayoutParameters = llpMWBM80; rgShooting1.LayoutParameters = llpMW; rgShooting2.LayoutParameters = llpWWC; rgShootMode.LayoutParameters = llpMW; //Drop down items var diffArrays = ArrayAdapter.CreateFromResource(this, Resource.Array.difficulty_array, Resource.Layout.spinner_item); diffArrays.SetDropDownViewResource(Resource.Layout.spinner_dd_items); ddlDiff.Adapter = diffArrays; ddlDiff.SetSelection(diffArrays.GetPosition("Challenging +0")); //Add methods etxtDiff.TextChanged += ResultChanger; etxtRoll.TextChanged += ResultChanger; ddlDiff.ItemSelected += DdlDiff_ItemSelected; rgShooting1.CheckedChange += RgShooting1_CheckedChange; rgShooting2.CheckedChange += RgShooting2_CheckedChange; rgShootMode.CheckedChange += RgShootMode_CheckedChange; //Order of insertion layoutbase.AddView(etxtDiff); layoutbase.AddView(etxtRoll); layoutbase.AddView(txtVResult); layoutbase.AddView(AddLine(8000)); relativebase.AddView(txtDiff); relativebase.AddView(ddlDiff); layoutbase.AddView(relativebase); //layoutbase.AddView(txtDiff); //layoutbase.AddView(ddlDiff); layoutbase.AddView(AddLine(8001)); layoutbase.AddView(rgShooting1); layoutbase.AddView(rgShooting2); layoutbase.AddView(AddLine(8002)); layoutbase.AddView(rgShootMode); //Layout layoutbase.Click += MainActivity_Click; imm = (InputMethodManager)GetSystemService(InputMethodService); }
protected async override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); building = new Building(); ViewModel = new BuildingsViewModel(); AppPreferences ap = new AppPreferences(Android.App.Application.Context); facilityId = Convert.ToInt32(ap.GetFacilityId()); userId = Convert.ToInt32(ap.GetUserId()); var data = Intent.GetStringExtra("data"); // Create your application here saveButton = FindViewById <FloatingActionButton>(Resource.Id.save_button); occupationYear = FindViewById <EditText>(Resource.Id.etb_occupationyear); occupationyearLayout = FindViewById <TextInputLayout>(Resource.Id.occupationyear_layout); gpscAddLocationButton = FindViewById <FloatingActionButton>(Resource.Id.gpscaddlocation_button); locationLinearlayout = FindViewById <LinearLayout>(Resource.Id.blocation_linearlayout); tvbLatitude = FindViewById <TextView>(Resource.Id.tvb_latitude); tvbLongitude = FindViewById <TextView>(Resource.Id.tvb_longitude); buildingPhoto = FindViewById <ImageView>(Resource.Id.imgb_buildingphoto); _GPSCoordinates = new GPSCoordinate(); buildingName = FindViewById <EditText>(Resource.Id.etb_name); buildingType = FindViewById <Spinner>(Resource.Id.sf_buildingtype); buildingstandard = FindViewById <Spinner>(Resource.Id.sf_buildingstandard); utilisationStatus = FindViewById <EditText>(Resource.Id.etb_utilisationstatus); nooOfFoors = FindViewById <EditText>(Resource.Id.etb_nooffloors); totalFootprintAream2 = FindViewById <EditText>(Resource.Id.etb_totalfootprintaream2); totalImprovedaAeam2 = FindViewById <EditText>(Resource.Id.etb_totalimprovedaream2); heritage = FindViewById <Switch>(Resource.Id.sf_heritage); disabledAccesss = FindViewById <Spinner>(Resource.Id.sf_disabledaccesss); disabledComment = FindViewById <EditText>(Resource.Id.etb_disabledcomment); constructionDescription = FindViewById <EditText>(Resource.Id.etb_constructiondescription); accuracyMessage = FindViewById <TextView>(Resource.Id.accuracy_message); refashAccuracy = FindViewById <FloatingActionButton>(Resource.Id.refreshaccuracy_button); refashAccuracy.Click += RefashAccuracy_Click; _dir = ap.CreateDirectoryForPictures(); Android.Content.Res.ColorStateList csl = new Android.Content.Res.ColorStateList(new int[][] { new int[0] }, new int[] { Android.Graphics.Color.ParseColor("#008000") }); gpscAddLocationButton.BackgroundTintList = csl; locationLinearlayout.Visibility = ViewStates.Gone; if (data != null) { building = Newtonsoft.Json.JsonConvert.DeserializeObject <Building>(data); isEdit = true; SupportActionBar.Title = "Edit Building"; occupationYear.Text = building.OccupationYear; if (building.GPSCoordinates != null) { tvbLatitude.Text = "Lat: " + building.GPSCoordinates.Latitude; tvbLongitude.Text = "Long: " + building.GPSCoordinates.Longitude; _GPSCoordinates = building.GPSCoordinates; locationLinearlayout.Visibility = ViewStates.Visible; } buildingName.Text = building.BuildingName; buildingType.SetSelection(GetIndex(buildingType, building.BuildingType)); buildingstandard.SetSelection(GetIndex(buildingstandard, building.BuildingStandard)); disabledAccesss.SetSelection(GetIndex(disabledAccesss, building.DisabledAccess)); utilisationStatus.Text = building.Status; nooOfFoors.Text = Convert.ToString(building.NumberOfFloors); totalFootprintAream2.Text = Convert.ToString(building.FootPrintArea); totalImprovedaAeam2.Text = Convert.ToString(building.ImprovedArea); heritage.Checked = building.Heritage; disabledComment.Text = building.DisabledComment; constructionDescription.Text = building.ConstructionDescription; Bitmap bit = SetImageBitmap(_dir + "/" + building.Photo); if (bit != null) { buildingPhoto.SetImageBitmap(bit); } else if (bit == null && !String.IsNullOrEmpty(building.Photo)) { PictureViewModel pictureViewModel = new PictureViewModel(); Models.Picture picture = await pictureViewModel.ExecuteGetPictureCommand(building.Photo); if (picture != null) { var _bit = ap.StringToBitMap(picture.File); if (_bit != null) { SaveImage(_bit, building.Photo); } buildingPhoto.SetImageBitmap(_bit); } } } else { SupportActionBar.Title = "Add New Building"; } saveButton.Click += SaveButton_Click; SupportActionBar.SetDisplayHomeAsUpEnabled(true); SupportActionBar.SetHomeButtonEnabled(true); gpscAddLocationButton.Click += AddLocation_Click; buildingPhoto.Click += (sender, e) => { ShowImage_Click(); }; GPSTracker GPSTracker = new GPSTracker(); Android.Locations.Location location = GPSTracker.GPSCoordinate(); if (location != null) { accuracyMessage.Text = String.Format("Accurate to {0} Meters", location.Accuracy.ToString()); } }
private void InitializeLocation(AlertDialog dialog) { int listViewMinimumHeight = 25; streetAddress = dialog.FindViewById <EditText>(Resource.Id.etf_streetAddress); suburb = dialog.FindViewById <EditText>(Resource.Id.etf_suburb); region = dialog.FindViewById <EditText>(Resource.Id.etf_region); province = dialog.FindViewById <Spinner>(Resource.Id.sf_province); localmunicipality = dialog.FindViewById <Spinner>(Resource.Id.sf_localmunicipality); locationCancelButton = dialog.FindViewById <Button>(Resource.Id.dfil_cancelbutton); locationDoneButton = dialog.FindViewById <Button>(Resource.Id.dfil_donebutton); gpsLocationButton = dialog.FindViewById <FloatingActionButton>(Resource.Id.gpscaddlocation_button); bpLocationButton = dialog.FindViewById <FloatingActionButton>(Resource.Id.bpaddlocation_button); refashAccuracy = dialog.FindViewById <FloatingActionButton>(Resource.Id.refreshaccuracy_button); tvfLatitude = dialog.FindViewById <TextView>(Resource.Id.tvf_latitude); tvfLongitude = dialog.FindViewById <TextView>(Resource.Id.tvf_longitude); boundaryPolygonsText = dialog.FindViewById <TextView>(Resource.Id.boundaryPolygonsText); accuracyMessage = dialog.FindViewById <TextView>(Resource.Id.accuracy_message); bpListView = dialog.FindViewById <ListView>(Resource.Id.bplistView1); itemList = new List <string>(); bpListView.SetMinimumHeight(listViewMinimumHeight); refashAccuracy.Click += RefashAccuracy_Click; if (facility.Location != null) { streetAddress.Text = facility.Location.StreetAddress; suburb.Text = facility.Location.Suburb; region.Text = facility.Location.Region; province.SetSelection(GetIndex(province, facility.Location.Province)); localmunicipality.SetSelection(GetIndex(localmunicipality, facility.Location.LocalMunicipality)); listViewMinimumHeight = listViewMinimumHeight * facility.Location.BoundryPolygon.Count(); if (facility.Location.GPSCoordinates != null) { tvfLatitude.Text = "Lat: " + facility.Location.GPSCoordinates.Latitude; tvfLongitude.Text = " Long: " + facility.Location.GPSCoordinates.Longitude; } if (facility.Location.BoundryPolygon != null) { bpListView.SetMinimumHeight(listViewMinimumHeight); _BoundryPolygons = new List <BoundryPolygon>(); foreach (var BoundaryPolygon in facility.Location.BoundryPolygon) { _BoundryPolygons.Add(BoundaryPolygon); itemList.Add("Lat: " + BoundaryPolygon.Latitude.ToString() + " Long: " + BoundaryPolygon.Longitude.ToString()); } arrayAdapter = new ArrayAdapter <string>(Activity, Resource.Layout.list_item, itemList); bpListView.Adapter = arrayAdapter; bpListView.ItemLongClick += Adapter_ItemSwipe; } boundaryPolygonsText.Text = String.Format("Boundary Polygons {0}", itemList.Count); } locationCancelButton.Click += LocationCancelButton_Click; locationDoneButton.Click += LocationDoneButton_Click; bpLocationButton.Click += BPLocationButton_Click; gpsLocationButton.Click += GPSLocationButton_Click; Android.Content.Res.ColorStateList csl = new Android.Content.Res.ColorStateList(new int[][] { new int[0] }, new int[] { Android.Graphics.Color.ParseColor("#008000") }); bpLocationButton.BackgroundTintList = csl; Android.Content.Res.ColorStateList cslf = new Android.Content.Res.ColorStateList(new int[][] { new int[0] }, new int[] { Android.Graphics.Color.ParseColor("#008000") }); gpsLocationButton.BackgroundTintList = cslf; if (isEdit) { streetAddress.Enabled = true; suburb.Enabled = true; region.Enabled = true; province.Enabled = true; localmunicipality.Enabled = true; locationDoneButton.Enabled = true; gpsLocationButton.Enabled = true; bpLocationButton.Enabled = true; } else { streetAddress.Enabled = false; suburb.Enabled = false; region.Enabled = false; province.Enabled = false; localmunicipality.Enabled = false; locationDoneButton.Enabled = false; gpsLocationButton.Enabled = false; bpLocationButton.Enabled = false; } GPSTracker GPSTracker = new GPSTracker(); Android.Locations.Location location = GPSTracker.GPSCoordinate(); if (location != null) { accuracyMessage.Text = String.Format("Accurate to {0} Meters", location.Accuracy.ToString()); } }