void BindContentView(ContentViewHolder holder, Cell formsCell, int position) { AView nativeCell = null; AView layout = holder.ItemView; holder.SectionIndex = CellCaches[position].SectionIndex; holder.RowIndex = CellCaches[position].RowIndex; nativeCell = holder.Body.GetChildAt(0); if (nativeCell != null) { holder.Body.RemoveViewAt(0); } nativeCell = CellFactory.GetCell(formsCell, nativeCell, _recyclerView, _context, _settingsView); if (position == _selectedIndex) { DeselectRow(); nativeCell.Selected = true; _preSelectedCell = nativeCell; } var minHeight = (int)Math.Max(_context.ToPixels(_settingsView.RowHeight), MinRowHeight); //it is neccesary to set both layout.SetMinimumHeight(minHeight); nativeCell.SetMinimumHeight(minHeight); if (!_settingsView.HasUnevenRows) { //if not Uneven, set the larger one of RowHeight and MinRowHeight. layout.LayoutParameters.Height = minHeight; } else if (formsCell.Height > -1) { //if the cell itself was specified height, set it. layout.SetMinimumHeight((int)_context.ToPixels(formsCell.Height)); layout.LayoutParameters.Height = (int)_context.ToPixels(formsCell.Height); } else { layout.LayoutParameters.Height = -2; //wrap_content } if (!CellCaches[position].IsLastCell || _settingsView.ShowSectionTopBottomBorder) { holder.Border.SetBackgroundColor(_settingsView.SeparatorColor.ToAndroid()); } else { holder.Border.SetBackgroundColor(Android.Graphics.Color.Transparent); } holder.Body.AddView(nativeCell, 0); }
void BindContentView(ContentBodyViewHolder holder, int position) { var formsCell = holder.RowInfo.Cell; AView nativeCell = null; AView layout = holder.ItemView; holder.RowInfo = _proxy[position]; nativeCell = holder.Body.GetChildAt(0); if (nativeCell != null) { holder.Body.RemoveViewAt(0); } nativeCell = CellFactory.GetCell(formsCell, nativeCell, _recyclerView, _context, _settingsView); if (position == _selectedIndex) { DeselectRow(); nativeCell.Selected = true; _preSelectedCell = nativeCell; } var minHeight = (int)Math.Max(_context.ToPixels(_settingsView.RowHeight), MinRowHeight); //it is neccesary to set both layout.SetMinimumHeight(minHeight); nativeCell.SetMinimumHeight(minHeight); if (!_settingsView.HasUnevenRows) { // if not Uneven, set the larger one of RowHeight and MinRowHeight. layout.LayoutParameters.Height = minHeight; } else if (formsCell.Height > -1) { // if the cell itself was specified height, set it. layout.SetMinimumHeight((int)_context.ToPixels(formsCell.Height)); layout.LayoutParameters.Height = (int)_context.ToPixels(formsCell.Height); } else if (formsCell is ViewCell viewCell) { // if used a viewcell, calculate the size and layout it. var size = viewCell.View.Measure(_settingsView.Width, double.PositiveInfinity); viewCell.View.Layout(new Rectangle(0, 0, size.Request.Width, size.Request.Height)); layout.LayoutParameters.Height = (int)_context.ToPixels(size.Request.Height); } else { layout.LayoutParameters.Height = -2; //wrap_content } holder.Body.AddView(nativeCell, 0); }
static void UpdateMinimumHeightFromParent(Context context, AView view, ListView listView) { if (!listView.HasUnevenRows && listView.RowHeight > 0) { view.SetMinimumHeight((int)context.ToPixels(listView.RowHeight)); } }
static void UpdateMinimumHeightFromParent(Context context, AView view, TableView table) { if (!table.HasUnevenRows && table.RowHeight > 0) { view.SetMinimumHeight((int)context.ToPixels(table.RowHeight)); } }
public View CreateTabContent(string tag) { var view = new View(_generator.TabHost.Context); view.SetMinimumWidth(0); view.SetMinimumHeight(0); return view; }
public View CreateTabContent(string tag) { var v = new View(_context); v.SetMinimumHeight(0); v.SetMinimumWidth(0); return v; }
AView GetHeaderView(AView convertView, TextCell formsCell) { TextView textView = null; if (convertView == null) { convertView = (_context as FormsAppCompatActivity).LayoutInflater.Inflate(Resource.Layout.HeaderCell, _listView, false); } //judging cell height int cellHeight = (int)_context.ToPixels(44); if (_settingsView.HeaderHeight > -1) { cellHeight = (int)_context.ToPixels(_settingsView.HeaderHeight); } convertView.SetMinimumHeight(cellHeight); convertView.LayoutParameters.Height = cellHeight; textView = convertView.FindViewById <TextView>(Resource.Id.HeaderCellText); var border = convertView.FindViewById <LinearLayout>(Resource.Id.HeaderCellBorder); //textview setting textView.SetPadding( (int)_context.ToPixels(_settingsView.HeaderPadding.Left), (int)_context.ToPixels(_settingsView.HeaderPadding.Top), (int)_context.ToPixels(_settingsView.HeaderPadding.Right), (int)_context.ToPixels(_settingsView.HeaderPadding.Bottom) ); textView.Gravity = _settingsView.HeaderTextVerticalAlign.ToNativeVertical() | GravityFlags.Left; textView.TextAlignment = Android.Views.TextAlignment.Gravity; textView.SetTextSize(Android.Util.ComplexUnitType.Sp, (float)_settingsView.HeaderFontSize); textView.SetBackgroundColor(_settingsView.HeaderBackgroundColor.ToAndroid()); textView.SetMaxLines(1); textView.SetMinLines(1); textView.Ellipsize = TextUtils.TruncateAt.End; if (_settingsView.HeaderTextColor != Xamarin.Forms.Color.Default) { textView.SetTextColor(_settingsView.HeaderTextColor.ToAndroid()); } //border setting if (_settingsView.ShowSectionTopBottomBorder) { border.SetBackgroundColor(_settingsView.SeparatorColor.ToAndroid()); } else { border.SetBackgroundColor(Android.Graphics.Color.Transparent); } //update text textView.Text = formsCell.Text; return(convertView); }
protected void WireUpForceUpdateSizeRequested(Cell cell, AView nativeCell) { cell.ForceUpdateSizeRequested -= _onForceUpdateSizeRequested; _onForceUpdateSizeRequested = delegate { // RenderHeight may not be changed, but that's okay, since we // don't actually use the height argument in the OnMeasure override. nativeCell.Measure(nativeCell.Width, (int)cell.RenderHeight); nativeCell.SetMinimumHeight(nativeCell.MeasuredHeight); nativeCell.SetMinimumWidth(nativeCell.MeasuredWidth); }; cell.ForceUpdateSizeRequested += _onForceUpdateSizeRequested; }
public override Dialog OnCreateDialog(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); // Begin building a new dialog. var builder = new AlertDialog.Builder(Activity); Rect displayRectangle = new Rect(); Window window = Activity.Window; window.DecorView.GetWindowVisibleDisplayFrame(displayRectangle); var inflater = Activity.LayoutInflater; dateView = inflater.Inflate(Resource.Layout.DateRange, null); dateView.SetMinimumHeight((int)(displayRectangle.Width() * 0.9f)); dateView.SetMinimumHeight((int)(displayRectangle.Height() * 0.9f)); Button butOk = dateView.FindViewById<Button> (Resource.Id.butok); butOk.Click+= ButOk_Click; datePicker1 = DatePicker.NewInstance(SetDateDlg1); datePicker2 = DatePicker.NewInstance(SetDateDlg2); EditText frd = dateView.FindViewById<EditText> (Resource.Id.trxdatefr); EditText tod = dateView.FindViewById<EditText> (Resource.Id.trxdateto); frd.Text = DateTime.Today.ToString ("dd-MM-yyyy"); frd.Click += delegate(object sender, EventArgs e) { datePicker1.Show(FragmentManager, "datePicker"); }; tod.Text = DateTime.Today.ToString ("dd-MM-yyyy"); tod.Click += delegate(object sender, EventArgs e) { datePicker2.Show(FragmentManager, "datePicker2"); }; builder.SetView (dateView); builder.SetPositiveButton ("CANCEL", HandlePositiveButtonClick); var dialog = builder.Create(); //Now return the constructed dialog to the calling activity return dialog; }
public void ShowToastMessage(string message, NotificationTypeEnum messageType) { Color backgroundHexColor = Color.ParseColor("#22c064"); if (messageType == NotificationTypeEnum.Info) { backgroundHexColor = Color.ParseColor("#1274d1"); } if (messageType == NotificationTypeEnum.Warning) { backgroundHexColor = Color.IndianRed; } if (messageType == NotificationTypeEnum.Danger) { backgroundHexColor = Color.Red; } var length = messageType == NotificationTypeEnum.Warning || messageType == NotificationTypeEnum.Danger ? ToastLength.Long : ToastLength.Short; // To dismiss existing toast, otherwise, the screen will be populated with it if the user do so _instance?.Cancel(); _instance = Toast.MakeText(Android.App.Application.Context, message, length); //_instance.SetGravity(GravityFlags.FillHorizontal | GravityFlags.Top, 0, 0); _instance.SetGravity(GravityFlags.Top, 0, 0); GradientDrawable gradientDrawable = new GradientDrawable(); gradientDrawable.SetCornerRadius(3f); //set corner radius //add icon and change background color/text TODO View tView = _instance.View; tView.SetMinimumHeight(40); tView.SetBackgroundDrawable(gradientDrawable); tView.Background.SetColorFilter(backgroundHexColor, PorterDuff.Mode.SrcIn);//Gets the actual oval background of the Toast then sets the color filter tView.SetPadding(10, 10, 10, 10); TextView text = (TextView)tView.FindViewById(Android.Resource.Id.Message); text.SetTextColor(Color.White); _instance.Show(); }
protected void WireUpForceUpdateSizeRequested(Cell cell, AView nativeCell) { ICellController cellController = cell; cellController.ForceUpdateSizeRequested -= _onForceUpdateSizeRequested; _onForceUpdateSizeRequested = (sender, e) => { if (nativeCell.Handle == IntPtr.Zero) { return; } // RenderHeight may not be changed, but that's okay, since we // don't actually use the height argument in the OnMeasure override. nativeCell.Measure(nativeCell.Width, (int)cell.RenderHeight); nativeCell.SetMinimumHeight(nativeCell.MeasuredHeight); nativeCell.SetMinimumWidth(nativeCell.MeasuredWidth); }; cellController.ForceUpdateSizeRequested += _onForceUpdateSizeRequested; }
void RefreshContent2() { LinearLayout.LayoutParams p = new LinearLayout.LayoutParams (LinearLayout.LayoutParams.MatchParent, LinearLayout.LayoutParams.WrapContent); foreach (var q in queue) { RelativeLayout rl = new RelativeLayout (Activity); rl.LayoutParameters = p; if (q.isSync) { rl.SetBackgroundColor (Android.Graphics.Color.LightGreen); } else { rl.SetBackgroundColor (Android.Graphics.Color.LightPink); } TextView type = new TextView (Activity); TextView loc = new TextView (Activity); switch (q.type) { case SyncQueueType.sqtAttendance: Attendance att = SyncQueueManager.GetAttendace (q.fileLoacation); Pharmacy pharm = PharmacyManager.GetPharmacy (att.pharmacy); type.Text = string.Format(@"Посещение аптеки {0} за дату {1}", pharm.fullName, att.date.ToString(@"d")); loc.Text = q.fileLoacation; break; case SyncQueueType.sqtAttendanceResult: AttendanceResult attRes = SyncQueueManager.GetAttendaceResult (q.fileLoacation); Attendance att2 = AttendanceManager.GetAttendance(attRes.attendance); Pharmacy pharm2 = PharmacyManager.GetPharmacy (att2.pharmacy); type.Text = string.Format(@"Значение по препарату в посещение аптеки {0} за дату {1}", pharm2.fullName, att2.date.ToString(@"d")); loc.Text = q.fileLoacation; break; case SyncQueueType.sqtAttendancePhoto: type.Text = string.Format(@"Фото"); loc.Text = q.fileLoacation; break; default: type.Text = @"Неизвестный тип файла"; type.SetTextColor (Android.Graphics.Color.DarkRed); break; } rl.AddView (type); RelativeLayout.LayoutParams rlLP = new RelativeLayout.LayoutParams (RelativeLayout.LayoutParams.WrapContent, RelativeLayout.LayoutParams.WrapContent); rlLP.AddRule(LayoutRules.Above, type.Id); loc.LayoutParameters = rlLP; rl.AddView (loc); View v = new View (Activity); v.SetMinimumHeight (2); rl.AddView (v); llSyncItems.AddView (rl); } }
AView GetContentView(AView convertView, Cell formsCell, ViewGroup parent, int position) { AView nativeCell = null; AView layout = convertView as AView; if (layout == null) { layout = (_context as FormsAppCompatActivity).LayoutInflater.Inflate(Resource.Layout.ContentCell, _listView, false); } var body = layout.FindViewById <LinearLayout>(Resource.Id.ContentCellBody); var border = layout.FindViewById(Resource.Id.ContentCellBorder); nativeCell = body.GetChildAt(0); if (nativeCell != null) { body.RemoveViewAt(0); } nativeCell = CellFactory.GetCell(formsCell, nativeCell, parent, _context, _settingsView); if (position == _selectedIndex) { DeselectRow(); nativeCell.Selected = true; _preSelectedCell = nativeCell; } var minHeight = (int)Math.Max(_context.ToPixels(_settingsView.RowHeight), MinRowHeight); //it is neccesary to set both layout.SetMinimumHeight(minHeight); nativeCell.SetMinimumHeight(minHeight); if (!_settingsView.HasUnevenRows) { //if not Uneven, set the larger one of RowHeight and MinRowHeight. layout.LayoutParameters.Height = minHeight; } else if (formsCell.Height > -1) { //if the cell itself was specified height, set it. layout.SetMinimumHeight((int)_context.ToPixels(formsCell.Height)); layout.LayoutParameters.Height = (int)_context.ToPixels(formsCell.Height); } else { layout.LayoutParameters.Height = -1; } if (!CellCaches[position].IsLastCell || _settingsView.ShowSectionTopBottomBorder) { border.SetBackgroundColor(_settingsView.SeparatorColor.ToAndroid()); } else { border.SetBackgroundColor(Android.Graphics.Color.Transparent); } body.AddView(nativeCell, 0); return(layout); }
TableRow GetDelim(Android.Graphics.Color color) { TableRow.LayoutParams lpDelim = new TableRow.LayoutParams (); lpDelim.Height = TableLayout.LayoutParams.WrapContent; lpDelim.Width = TableLayout.LayoutParams.WrapContent; lpDelim.SetMargins (ToDIP(2), ToDIP(1), ToDIP(2), ToDIP(1)); // lpDelim.Span = currentAttendances.Count + 2; lpDelim.Span = newAttendanceResults.Count + 2; TableRow rDelim = new TableRow (Activity); View vDelim = new View (Activity); vDelim.SetMinimumHeight (ToDIP(3)); vDelim.SetBackgroundColor (color); vDelim.LayoutParameters = lpDelim; rDelim.AddView (vDelim); return rDelim; }
static void UpdateMinimumHeightFromParent(Context context, AView view, ListView listView) { if (!listView.HasUnevenRows && listView.RowHeight > 0) view.SetMinimumHeight((int)context.ToPixels(listView.RowHeight)); }
static void UpdateMinimumHeightFromParent(Context context, AView view, TableView table) { if (!table.HasUnevenRows && table.RowHeight > 0) view.SetMinimumHeight((int)context.ToPixels(table.RowHeight)); }
protected void WireUpForceUpdateSizeRequested(Cell cell, AView nativeCell) { cell.ForceUpdateSizeRequested -= _onForceUpdateSizeRequested; _onForceUpdateSizeRequested = delegate { // RenderHeight may not be changed, but that's okay, since we // don't actually use the height argument in the OnMeasure override. nativeCell.Measure(nativeCell.Width, (int)cell.RenderHeight); nativeCell.SetMinimumHeight(nativeCell.MeasuredHeight); nativeCell.SetMinimumWidth(nativeCell.MeasuredWidth); }; cell.ForceUpdateSizeRequested += _onForceUpdateSizeRequested; }
private void BindContentView(ContentViewHolder holder, Cell formsCell, int position) { AView nativeCell = null; AView layout = holder.ItemView; holder.SectionIndex = CellCaches[position].SectionIndex; holder.RowIndex = CellCaches[position].RowIndex; nativeCell = holder.Body.GetChildAt(0); if (nativeCell != null) { holder.Body.RemoveViewAt(0); } nativeCell = CellFactory.GetCell(formsCell, nativeCell, _recyclerView, _context, _boxedView); if (position == _selectedIndex) { DeselectRow(); nativeCell.Selected = true; _preSelectedCell = nativeCell; } var minHeight = (int)Math.Max(_context.ToPixels(_boxedView.RowHeight), MinRowHeight); // It is necessary to set both layout.SetMinimumHeight(minHeight); nativeCell.SetMinimumHeight(minHeight); if (!_boxedView.HasUnevenRows) { // If not Uneven, set the larger one of RowHeight and MinRowHeight. layout.LayoutParameters.Height = minHeight; } else if (formsCell.Height > -1) { // If the cell itself was specified height, set it. layout.SetMinimumHeight((int)_context.ToPixels(formsCell.Height)); layout.LayoutParameters.Height = (int)_context.ToPixels(formsCell.Height); } else if (formsCell is ViewCell viewCell) { // If used a viewcell, calculate the size and layout it. var size = viewCell.View.Measure(_boxedView.Width, double.PositiveInfinity); viewCell.View.Layout(new Rectangle(0, 0, size.Request.Width, size.Request.Height)); layout.LayoutParameters.Height = (int)_context.ToPixels(size.Request.Height); } else { layout.LayoutParameters.Height = -2; // wrap_content } if (!CellCaches[position].IsLastCell || _boxedView.ShowSectionTopBottomBorder) { holder.Border.SetBackgroundColor(_boxedView.SeparatorColor.ToAndroid()); } else { holder.Border.SetBackgroundColor(Android.Graphics.Color.Transparent); } holder.Body.AddView(nativeCell, 0); }