private void CreateLandingItemsFromList(List <List <LandingItem> > landingItems) { LinearLayout rootLandingLayout = FindViewById <LinearLayout> (Resource.Id.LandingLayout); foreach (List <LandingItem> landingItemsPerLine in landingItems) { LinearLayout linearLayout = new LinearLayout(this); LayoutParams layoutParams = new LayoutParams(LayoutParams.MatchParent, LayoutParams.WrapContent); layoutParams.Weight = 1; linearLayout.LayoutParameters = layoutParams; linearLayout.Orientation = Orientation.Horizontal; if (landingItemsPerLine.Count == 1 && landingItemsPerLine [0] is MyDayItem) { linearLayout.AddView(this.LayoutInflater.Inflate(Resource.Layout.my_day_item, null)); } else if (landingItemsPerLine.Count == 1 && landingItemsPerLine [0] is TransactionsItem) { linearLayout.AddView(this.LayoutInflater.Inflate(Resource.Layout.transactions_item, null)); } else { this.CreateLandingItemsForRow(linearLayout, landingItemsPerLine); } rootLandingLayout.AddView(linearLayout); } }
protected override void OnElementChanged(ElementChangedEventArgs <ReceiverView> e) { base.OnElementChanged(e); if (Control == null) { var layoutparams = new Android.Widget.LinearLayout.LayoutParams(LayoutParams.MatchParent, LayoutParams.MatchParent); _streamImage = new ImageView(Context); _streamImage.LayoutParameters = layoutparams; var mainView = new Android.Widget.LinearLayout(this.Context); mainView.AddView(_streamImage); SetNativeControl(mainView); } if (Control == null || Element == null) { return; } if (e.OldElement != null) { //Element being deleted } if (e.NewElement != null) { //Element being created } }
void configPicker(out WheelPicker picker, List <string> data) { picker = new WheelPicker(this.Context); //TODO maybe use format string is better here.. for (int i = 0; i < data.Count; i++) { var d = data[i]; if (int.Parse(d) < 10) { data[i] = "0" + d; } } var layoutParams = new Android.Widget.LinearLayout.LayoutParams(LayoutParams.WrapContent, LayoutParams.WrapContent); layoutParams.SetMargins(10, 0, 10, 0); picker.LayoutParameters = layoutParams; picker.SetAtmospheric(true); picker.Curved = true; var ucolor = ColorToUInt(System.Drawing.Color.DarkGray); picker.SelectedItemTextColor = unchecked ((int)ucolor); picker.Data = data; picker.SetOnItemSelectedListener(selectedClass); }
public static Android.Widget.LinearLayout.LayoutParams GetCurrentVideoContainerLayout() { Android.Widget.LinearLayout.LayoutParams vidParams = new Android.Widget.LinearLayout.LayoutParams(AppState.Display.ScreenWidth, (int)(AppState.Display.ScreenWidth * (.5625))); return(vidParams); }
protected void init() { recyclerView = FindViewById <RecyclerView>(Resource.Id.recyclerView); drawView = new DrawView(this, 96 * multiply, 64 * multiply, multiply, typeface); Android.Widget.LinearLayout.LayoutParams lp = new Android.Widget.LinearLayout.LayoutParams(96 * multiply, 64 * multiply); lp.SetMargins(10, 10, 10, 10); lp.Gravity = GravityFlags.Center; drawView.LayoutParameters = lp; drawView.SetBackgroundColor(Android.Graphics.Color.ParseColor("#000000")); }
private void Init() { RemoveAllViews(); Orientation = Orientation.Horizontal; LayoutParams lp = new LayoutParams(LayoutParams.WrapContent, LayoutParams.WrapContent); lp.Gravity = GravityFlags.CenterVertical; LayoutParameters = lp; cardImageLayout = new FrameLayout(Context); LayoutParams cardImageLayoutParams = new LayoutParams(LayoutParams.WrapContent, LayoutParams.WrapContent); cardImageLayoutParams.Gravity = GravityFlags.CenterVertical; cardImageLayout.LayoutParameters = cardImageLayoutParams; cardImageLayout.SetPadding(0, 0, UiUtils.ToPixels(Context, 8), 0); SetCardImageWithoutAnimation(Resource.Drawable.ic_card_cv2); cv2TextView = new CV2TextView(Context); LayoutParams parameters = new LayoutParams(LayoutParams.WrapContent, LayoutParams.WrapContent); parameters.Weight = 1; parameters.Gravity = GravityFlags.Center; cv2TextView.LayoutParameters = parameters; cv2TextView.OnEntryComplete += cardNumber => { if (OnCreditCardEntered != null) { OnCreditCardEntered(cardNumber); } }; LayoutParams textViewLayoutParams = new LayoutParams(LayoutParams.WrapContent, LayoutParams.MatchParent); textViewLayoutParams.Gravity = GravityFlags.Center; last4CCNosTextView = new TextView(Context); last4CCNosTextView.Gravity = GravityFlags.Center; last4CCNosTextView.Text = "0000"; last4CCNosTextView.LayoutParameters = textViewLayoutParams; last4CCNosTextView.SetTypeface(Typeface.Monospace, TypefaceStyle.Normal); last4CCNosTextView.TextSize = 18; last4CCNosTextView.SetTextColor(Resources.GetColor(Resource.Color.normal_text)); last4CCNosTextView.Focusable = false; last4CCNosTextView.Enabled = false; last4CCNosTextView.SetSingleLine(); last4CCNosTextView.SetBackgroundDrawable(null); AddView(cardImageLayout); AddView(last4CCNosTextView); AddView(cv2TextView); }
void NewElement_Clicked(object sender, EventArgs e) { var d = new Dialog(Xamarin.Forms.Forms.Context); d.SetTitle((this.Element as ButtonOpenDialog).TitleModal); var renderer = RendererFactory.GetRenderer((this.Element as ButtonOpenDialog).ContentModal); // TODO : à ajuster Android.Widget.LinearLayout.LayoutParams params1 = new Android.Widget.LinearLayout.LayoutParams(LayoutParams.WrapContent, LayoutParams.WrapContent); params1.Height = 300; d.AddContentView(renderer.ViewGroup, params1); d.Show(); this.UpdateLayout(); }
public CustomerSearchTypeView(StringHelper stringHelper, bool titleMode, string label, string type, string image) { Orientation = Android.Widget.Orientation.Horizontal; _stringHelper = stringHelper; _helper = new MobileCustomerSearchHelper(); TitleMode = titleMode; Label = label; CustomerType = type; Image = image; this.SetWillNotDraw(false); this.SetAccessibilityIdentifier(string.Format("TYPE:{0}", CustomerType)); if (TitleMode) { this.SetBackgroundColor(StyleGuide.OpaqueSkinColor); this.TitleLabel = Label; _selectAllButton = new SelectAllButton(stringHelper, _helper); _selectAllButton.Click += Handle_selectAllButtonTouchDown; var layoutParameters = new Android.Widget.LinearLayout.LayoutParams( Android.Views.ViewGroup.LayoutParams.WrapContent, Android.Views.ViewGroup.LayoutParams.WrapContent); layoutParameters.Gravity = Android.Views.GravityFlags.Center; _selectAllButton.LayoutParameters = layoutParameters; this.AddView(_selectAllButton); //this.SizeToFit(); } else { this.CustImage = ImageUrlHelper.GetImage(Image); this.CustTypeLabel = Label;; _selectCust = new CdlCheckBoxFactory.MultiCheckBox(false); _selectCust.On = false; _selectCust.On = _helper.IsSelected; _selectCust.ValueChanged += Handle_selectCustValueChanged; var layoutParameters = new Android.Widget.LinearLayout.LayoutParams( Android.Views.ViewGroup.LayoutParams.WrapContent, Android.Views.ViewGroup.LayoutParams.WrapContent); layoutParameters.SetMargins(8.px(), 8.px(), 8.px(), 8.px()); layoutParameters.Gravity = Android.Views.GravityFlags.Center; _selectCust.LayoutParameters = layoutParameters; this.AddView(_selectCust); //this.SizeToFit(); } }
void AddCustomMenuView() { try { if (isCustomViewAdded) { this.RemoveView(actionBarCustomView); this.RemoveViewInLayout(actionBarCustomView); } //var layout = new Android.Widget.RelativeLayout.LayoutParams( // Android.Widget.RelativeLayout.LayoutParams.MatchParent, Android.Widget.RelativeLayout.LayoutParams.WrapContent); //actionBarCustomView.Id = 2; //layout.AddRule(LayoutRules.CenterInParent, actionBarCustomView.Id); //Display display = _activity.WindowManager.DefaultDisplay; //Android.Graphics.Point size = new Android.Graphics.Point(); //display.GetSize(size); //int height = size.Y; var layout = new Android.Widget.LinearLayout.LayoutParams( ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent); layout.Gravity = GravityFlags.Bottom; //layout.SetMargins(0, height, 0, 0); //var windowManager = this.Context.GetSystemService(Context.WindowService).JavaCast<IWindowManager>(); //var layout = new WindowManagerLayoutParams( // 0, 500, // ViewGroup.LayoutParams.MatchParent, // ViewGroup.LayoutParams.WrapContent, // WindowManagerTypes.Phone, // WindowManagerFlags.Fullscreen, // Format.Translucent); //layout.Gravity = GravityFlags.Bottom; actionBarCustomView.SetBackgroundColor(myTabbedPage.TabBackgroundColor.ToAndroid()); this.AddView(actionBarCustomView, layout); isCustomViewAdded = true; } catch (Exception) { this.RemoveView(actionBarCustomView); this.RemoveViewInLayout(actionBarCustomView); AddCustomMenuView(); } }
private void FillSideIndexBar() { List <string> firstLetters = new List <string> (this.Customers.Keys); foreach (string letter in firstLetters) { TextView textView = new TextView(this); textView.Text = letter; LayoutParams layoutParams = new LayoutParams(LayoutParams.WrapContent, LayoutParams.MatchParent); layoutParams.Weight = 1; textView.LayoutParameters = layoutParams; this.SideIndexBar.AddView(textView); } }
public void SetHeight(int height) { Android.Widget.LinearLayout.LayoutParams newLayout; if (ItemView.LayoutParameters != null) { newLayout = new Android.Widget.LinearLayout.LayoutParams(ItemView.LayoutParameters); } else { newLayout = new Android.Widget.LinearLayout.LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent); } newLayout.Width = ItemView.LayoutParameters?.Width ?? ViewGroup.LayoutParams.MatchParent; newLayout.Height = height; ItemView.LayoutParameters = newLayout; }
private Android.Views.View CreateLayout(Context context) { Android.Widget.RelativeLayout layout = new Android.Widget.RelativeLayout(context); var layoutParam = new Android.Widget.RelativeLayout.LayoutParams(LayoutParams.WrapContent, LayoutParams.WrapContent); layout.SetPadding(30, 15, 30, 15); layout.LayoutParameters = layoutParam; //main layout Android.Widget.LinearLayout mainView = new Android.Widget.LinearLayout(context); var paramLayout = new Android.Widget.RelativeLayout.LayoutParams(LayoutParams.WrapContent, LayoutParams.WrapContent); mainView.Orientation = Orientation.Vertical; paramLayout.AddRule(NativeCell.IsIncoming ? LayoutRules.AlignParentLeft : LayoutRules.AlignParentRight); paramLayout.SetMargins(NativeCell.IsIncoming ? 0 : 50, 0, NativeCell.IsIncoming ? 50 : 0, 0); mainView.SetPadding(30, 30, 30, 30); mainView.LayoutParameters = paramLayout; //set drawable GradientDrawable shape = new GradientDrawable(); shape.SetCornerRadius(NativeCell.CornerRadius * 2); shape.SetColor(NativeCell.IsIncoming ? NativeCell.IncomingColor.ToAndroid() : NativeCell.OutgoingColor.ToAndroid()); mainView.Background = shape; // name text NameText = new TextView(context); NameText.SetTextColor(NativeCell.NameFontColor.ToAndroid()); NameText.TextSize = NativeCell.NameFontSize; NameText.Text = NativeCell.Name; NameText.Id = Name_Text_Id; var paramNameText = new Android.Widget.LinearLayout.LayoutParams(LayoutParams.WrapContent, LayoutParams.WrapContent); NameText.LayoutParameters = paramNameText; //message text MessageText = new TextView(context); MessageText.SetTextColor(NativeCell.TextFontColor.ToAndroid()); MessageText.Text = NativeCell.MessageBody; MessageText.TextSize = NativeCell.TextFontSize; MessageText.Id = Message_Text_Id; var paramMessageText = new Android.Widget.LinearLayout.LayoutParams(LayoutParams.WrapContent, LayoutParams.WrapContent); MessageText.LayoutParameters = paramMessageText; // status layout LinearLayout linearLayout = new LinearLayout(context); linearLayout.Orientation = Orientation.Horizontal; var paramlinearLayout = new Android.Widget.LinearLayout.LayoutParams(LayoutParams.WrapContent, LayoutParams.WrapContent); paramlinearLayout.Gravity = Android.Views.GravityFlags.Right; linearLayout.SetGravity(Android.Views.GravityFlags.Right); linearLayout.LayoutParameters = paramlinearLayout; // status text StatusText = new TextView(context); StatusText.SetTextColor(NativeCell.InfoFontColor.ToAndroid()); StatusText.Text = StatusHelper.GetStatusString(NativeCell.Status); StatusText.Id = Status_Text_Id; StatusText.TextSize = NativeCell.InfoFontSize; StatusText.SetPadding(0, 0, 10, 0); StatusText.Gravity = Android.Views.GravityFlags.Left; var paramStatusText = new Android.Widget.LinearLayout.LayoutParams(LayoutParams.WrapContent, LayoutParams.WrapContent); paramStatusText.Gravity = Android.Views.GravityFlags.Left; StatusText.LayoutParameters = paramStatusText; if (!NativeCell.IsIncoming) { linearLayout.AddView(StatusText); } // date text DateText = new TextView(context); DateText.SetTextColor(NativeCell.InfoFontColor.ToAndroid()); DateText.Text = NativeCell.Date; DateText.SetLines(1); DateText.TextSize = NativeCell.InfoFontSize; DateText.SetMinWidth(LayoutParams.WrapContent); DateText.Id = Date_Text_Id; var paramDateText = new Android.Widget.LinearLayout.LayoutParams(LayoutParams.WrapContent, LayoutParams.WrapContent); DateText.LayoutParameters = paramDateText; linearLayout.AddView(DateText); if (!string.IsNullOrWhiteSpace(NameText.Text) && NativeCell.IsIncoming) { mainView.AddView(NameText); } mainView.AddView(MessageText); mainView.AddView(linearLayout); layout.AddView(mainView); return(layout); }
/// <summary> /// Initialise la popup de l'ajout d'une zone en favoris /// </summary> private void BuildAreaAddFavorisPopup() { // création d'une alerte dialog _addModeZoneFavorisAlertDialog = new AlertDialog.Builder(this); var editText = new EditText(this); var editTextLayout = new LinearLayout(this); var editTextParam = new Android.Widget.LinearLayout.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent); editTextParam.SetMargins(25, 5, 25, 5); editText.InputType = Android.Text.InputTypes.TextVariationUri; editText.SetHint(Resource.String.addFavoriteArea_areaName); editText.SetTextColor(Android.Graphics.Color.ParseColor("#cccccc")); // TODO : dans fichier ressource editText.SetHintTextColor(Android.Graphics.Color.ParseColor("#888888")); // TODO : dans fichier ressource editText.LayoutParameters = editTextParam; var editTextLayoutParam = new Android.Widget.LinearLayout.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.WrapContent); editTextLayoutParam.SetMargins(20, 5, 20, 5); editTextLayout.LayoutParameters = editTextLayoutParam; editTextLayout.AddView(editText); // titre de l'alerte _addModeZoneFavorisAlertDialog.SetTitle(Resource.String.modeZone_addAreaFavorisTitle); // bouton ajouter _addModeZoneFavorisAlertDialog.SetPositiveButton(Resource.String.popup_add, async(o, e) => { if (string.IsNullOrEmpty(editText.Text)) { return; } var pointCount = 0; if (_mapControlManager.ZonePolygon != null) { if (_mapControlManager.ZonePolygon.Points.Count == 1) { pointCount = 1; } else { pointCount = _mapControlManager.ZonePolygon.Points.Count - 1; } var trame = GetTrame(_mapControlManager.ZonePolygon.Points.ToList()); var surface = AreaHelper.CalculateAreaOfGPSPolygonOnEarthInSquareMeters(_mapControlManager.ZonePolygon.Points.ToList()); LoadingLayout.Visibility = ViewStates.Visible; var result = await App.Locator.ModeZone.AddFavoriteArea(new FavoriteAreaDTO { Trame = trame, PointsCount = pointCount, AreaGeodesic = surface, AreaName = editText.Text.ToUpperCaseFirst(), }); if (result) { var textAddedAreaToast = string.Format(Resources.GetString(Resource.String.modeZone_toast_AddedArea), editText.Text.ToUpperCaseFirst()); Toast.MakeText(this, textAddedAreaToast, ToastLength.Long).Show(); } LoadingLayout.Visibility = ViewStates.Gone; } else { string error = Resources.GetString(Resource.String.addFavoriteArea_errorZone); AlertDialog alertMessage = new AlertDialog.Builder(this).Create(); alertMessage.SetTitle("Error: "); alertMessage.SetMessage(error); alertMessage.Show(); } _addModeZoneFavorisDialog.Dismiss(); }); // bouton annuler _addModeZoneFavorisAlertDialog.SetNegativeButton(Resource.String.popup_cancelled, (o, e) => { _addModeZoneFavorisDialog.Dismiss(); }); // ajout de la vue dans l'alerte _addModeZoneFavorisAlertDialog.SetView(editTextLayout); // instatiation de notre popup dans un objet dialog _addModeZoneFavorisDialog = _addModeZoneFavorisAlertDialog.Create(); _addModeZoneFavorisAlertDialog.Show(); }