void SetupUserInterface() { topLayout = new RelativeLayout(Context); mainLayout = new RelativeLayout(Context); //RelativeLayout.LayoutParams mainLayoutParams = new RelativeLayout.LayoutParams( // RelativeLayout.LayoutParams.MatchParent, // RelativeLayout.LayoutParams.MatchParent); //mainLayout.LayoutParameters = mainLayoutParams; liveView = new TextureView(Context); RelativeLayout.LayoutParams liveViewParams = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.MatchParent, RelativeLayout.LayoutParams.MatchParent); liveView.LayoutParameters = liveViewParams; mainLayout.AddView(liveView); capturePhotoButton = new PaintCodeButton(Context); RelativeLayout.LayoutParams captureButtonParams = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.WrapContent, RelativeLayout.LayoutParams.WrapContent); captureButtonParams.Height = 120; captureButtonParams.Width = 120; capturePhotoButton.LayoutParameters = captureButtonParams; mainLayout.AddView(capturePhotoButton); AddView(mainLayout); }
protected override View GetViewImpl(Context context, View convertView, ViewGroup parent) { if (scaled == null) { scaled = Scale(Value); } Click = delegate { SelectImage(); }; var view = convertView as RelativeLayout ?? new RelativeLayout(context); var parms = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent); parms.SetMargins(5, 2, 5, 2); parms.AddRule(LayoutRules.AlignParentLeft); // SEC bug fix, not yet submitted to Kenny. Getting exception "specified view already has a parent" if (scaled.Parent != view) { view.AddView(scaled, parms); } return(view); }
private void attachSubscriberView(Subscriber subscriber) { RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(Resources.DisplayMetrics.widthPixels, Resources.DisplayMetrics.heightPixels); mSubscriberViewContainer.removeView(mSubscriber.View); mSubscriberViewContainer.addView(mSubscriber.View, layoutParams); subscriber.setStyle(BaseVideoRenderer.STYLE_VIDEO_SCALE, BaseVideoRenderer.STYLE_VIDEO_FILL); }
//here we only have img and text for each item //create a RelativeLayout and add it to dic //squear image public void AddItem(int imgresource,string text,Action OnCellClick) { RelativeLayout menucell = new RelativeLayout (nn_context); menucell.SetPadding (TapUtil.dptodx(padding),TapUtil.dptodx(padding),TapUtil.dptodx(padding),TapUtil.dptodx(padding)); menucell.LayoutParameters = new LinearLayout.LayoutParams (TapUtil.dptodx(cellwidth),TapUtil.dptodx(cellheight)); menucell.Click+= (object sender, EventArgs e) => { if(OnCellClick!=null){ OnCellClick(); } }; ImageView img = new ImageView (nn_context); img.Id = TapUtil.generateViewId (); img.LayoutParameters = new RelativeLayout.LayoutParams (TapUtil.dptodx(imagewidth),TapUtil.dptodx(imagewidth)); // Bitmap.CreateScaledBitmap(imgresource, TapUtil.dptodx(imagewidth), TapUtil.dptodx(imageheight), false); img.SetImageResource (imgresource); img.SetBackgroundColor (Color.White); TextView textview = new TextView (nn_context); RelativeLayout.LayoutParams textviewparam=new RelativeLayout.LayoutParams (TapUtil.dptodx(textwidth),TapUtil.dptodx(textheight)); textviewparam.AddRule(LayoutRules.RightOf,img.Id); textviewparam.LeftMargin = TapUtil.dptodx (space); textview.LayoutParameters =textviewparam; textview.Text = text; textview.SetTypeface (Typeface.Default, TypefaceStyle.Bold); textview.SetTextColor(Color.Black); textview.Gravity = global::Android.Views.GravityFlags.Center; menucell.AddView (img); menucell.AddView (textview); nn_itemlist.Add (menucell); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); var rl = new RelativeLayout(this); var layoutParams = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.FillParent, ViewGroup.LayoutParams.FillParent); rl.LayoutParameters = layoutParams; var surfaceOrientation = WindowManager.DefaultDisplay.Rotation; RelativeLayout.LayoutParams tvLaoutParams; tvLaoutParams = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.FillParent, ViewGroup.LayoutParams.WrapContent); if (surfaceOrientation == SurfaceOrientation.Rotation0 || surfaceOrientation == SurfaceOrientation.Rotation180) { } else { tvLaoutParams.LeftMargin = tvLaoutParams.TopMargin = 200; } var textView = new TextView(this); textView.LayoutParameters = tvLaoutParams; textView.Text = "Programatic Layout"; rl.AddView(textView); SetContentView(rl); }
public void AddActionItem(ActionItem item) { _actionItems.Add(item); var container = CreateActionItemContainer(); DisplayIcon(container, item); DisplayTitle(container, item); if (_orientation == QuickActionLayout.Horizontal && _childPos != 0) { var separator = _inflater.Inflate(Resource.Layout.horiz_separator, null); var parms = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent); separator.LayoutParameters = parms; separator.SetPadding(5, 0, 5, 0); _track.AddView(separator, _insertPos); _insertPos++; } _track.AddView(container, _insertPos); _childPos++; _insertPos++; }
protected override void OnLayout(bool changed, int l, int t, int r, int b) { base.OnLayout(changed, l, t, r, b); if (!fDidLayout) { // r = _mainActivity._ptScreenSize.X; Rect rect = new Rect(l, t, r, b); "rect = ({rect.Left},{ rect.Top}) ({rect.Right},{rect.Bottom})".ToString(); _ptCircleCtr = new Point(rect.Left + (rect.Right - rect.Left) / 2, rect.Top + (rect.Bottom - rect.Top) / 2); if (_ptCircleCtr.X != 0 && _ptCircleCtr.Y != 0) { fDidLayout = true; // this._mainActivity._txtWordSoFar.Text = _ptCircleCtr.ToString() + " " + rect.ToString(); // _circRadius = (rect.Right - rect.Left) / 2; int ndx = 0; var radsPerLetter = (2 * Math.PI / _lstLtrWheelLetterLayouts.Count); foreach (var ltr in _lstLtrWheelLetterLayouts) { var x = _ptCircleCtr.X + _pctRadiusLettersInCircle * _circRadius * Math.Cos(radsPerLetter * ndx); // - ltr.Width / 2; var y = _ptCircleCtr.Y - _pctRadiusLettersInCircle * _circRadius * Math.Sin(radsPerLetter * ndx); // - ltr.Height / 2; var letpt = new Point((int)x, (int)y); var layoutParametersWheel = new RelativeLayout.LayoutParams(ltr.Width, ltr.Height); layoutParametersWheel.LeftMargin = letpt.X - rect.Left;// + _circRadius / 2 + 40; layoutParametersWheel.TopMargin = letpt.Y - rect.Top + _circRadius / 2 + 40; ltr.LayoutParameters = layoutParametersWheel; ndx++; } } } }
public MenuButton(int resource, Context context) : base(context) { this.context = context; SetBackgroundResource(resource); int size = (int)(SmallerScreenMetric / 6.5); int margin = size / 5; RelativeLayout.LayoutParams parameters = new RelativeLayout.LayoutParams(size, size); parameters.RightMargin = margin; parameters.BottomMargin = margin; parameters.AddRule(LayoutRules.AlignParentRight); parameters.AddRule(LayoutRules.AlignParentBottom); LayoutParameters = parameters; if (Build.VERSION.SdkInt > BuildVersionCodes.Lollipop) { Elevation = 3; } else { // No elevation for you, my friend } }
public void ShowSessionControls(Activity activity, Session session) { if (_overlayIndicator != null) { return; } if (!(activity is FormsAppCompatActivity)) { return; } var indicator = new CobrowseCustomView(); var renderer = Platform.CreateRendererWithContext(indicator, activity); renderer.Element.Layout(new Xamarin.Forms.Rectangle(0, 0, indicator.WidthRequest, indicator.HeightRequest)); var nativeIndicator = renderer.View; var modal = new RelativeLayout(activity); var layoutParams = new RelativeLayout.LayoutParams( (int)TypedValue.ApplyDimension(ComplexUnitType.Dip, (float)indicator.WidthRequest, activity.Resources.DisplayMetrics), (int)TypedValue.ApplyDimension(ComplexUnitType.Dip, (float)indicator.HeightRequest, activity.Resources.DisplayMetrics)) { MarginEnd = (int)TypedValue.ApplyDimension(ComplexUnitType.Dip, 4f, activity.Resources.DisplayMetrics) }; layoutParams.AddRule(LayoutRules.CenterVertical); layoutParams.AddRule(LayoutRules.AlignParentEnd); modal.AddView(nativeIndicator, layoutParams); var rootFrameLayout = (ViewGroup)activity.Window.PeekDecorView(); rootFrameLayout.AddView(modal, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent)); rootFrameLayout.Invalidate(); _overlayIndicator = modal; }
public override View GetView(Context context, View convertView, ViewGroup parent) { var view = new RelativeLayout(context); var parms = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent); parms.SetMargins(5, 3, 5, 0); parms.AddRule(LayoutRules.CenterVertical); tv = new TextView(context) { Text = Caption, TextSize = 16f }; view.AddView(tv, parms); var sparms = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent); sparms.SetMargins(5, 3, 5, 0); sparms.AddRule(LayoutRules.CenterVertical); sparms.AddRule(LayoutRules.AlignParentRight); sw = new ToggleButton(context) { Tag = 1, Checked = Value }; view.AddView(sw, sparms); return(view); }
public NotListView(List <Product> list, LinearLayout mainLayout, Context context) { for (int i = 0; i < list.Count; i++) { RelativeLayout productView = new RelativeLayout(context); ImageView productImage = new ImageView(context); productImage.SetImageDrawable(list [i].GetImage(context)); productImage.Id = i * 10 + 1; RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent); lp.AddRule(LayoutRules.AlignParentLeft); lp.AddRule(LayoutRules.CenterVertical); TextView productTitle = new TextView(context); productTitle.Id = i * 10 + 2; lp.AddRule(LayoutRules.AlignRight, productImage.Id); productView.AddView(productImage); productView.AddView(productTitle); //.... mainLayout.AddView(productView); } }
public override View GetView (Context context, View convertView, ViewGroup parent) { var view = new RelativeLayout(context); var parms = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent); view.SetMinimumHeight(150); parms.SetMargins(5, 3, 5, 0); parms.AddRule(LayoutRules.AlignParentLeft); _caption = new TextView (context); SetCaption (Caption); view.AddView(_caption, parms); if (!String.IsNullOrWhiteSpace (Indicator)) { var tparms = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent); tparms.SetMargins(5, 3, 5, 5); tparms.AddRule(LayoutRules.CenterVertical); tparms.AddRule(LayoutRules.AlignParentRight); _text = new TextView (context) { Text = Indicator, TextSize = 22f }; view.AddView(_text, tparms); } return view; }
public static void showPopupSettings() { RelativeLayout popupContainer = (RelativeLayout)Shared.Activity.FindViewById(Resource.Id.popup_container); popupContainer.RemoveAllViews(); // background ImageView imageView = new ImageView(Application.Context); imageView.SetBackgroundColor(Color.ParseColor("#88555555")); imageView.LayoutParameters = new RelativeLayout.LayoutParams(1, 1); imageView.Clickable = true; popupContainer.AddView(imageView); // popup PopupSettingsView popupSettingsView = new PopupSettingsView(Application.Context); int width = Application.Context.Resources.GetDimensionPixelSize(Resource.Dimension.popup_settings_width); int height = Application.Context.Resources.GetDimensionPixelSize(Resource.Dimension.popup_settings_height); RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(width, height); layoutParams.AddRule(LayoutRules.CenterInParent); popupContainer.AddView(popupSettingsView, layoutParams); // animate all together ObjectAnimator scaleXAnimator = ObjectAnimator.OfFloat(popupSettingsView, "scaleX", 0f, 1f); ObjectAnimator scaleYAnimator = ObjectAnimator.OfFloat(popupSettingsView, "scaleY", 0f, 1f); ObjectAnimator alphaAnimator = ObjectAnimator.OfFloat(imageView, "alpha", 0f, 1f); AnimatorSet animatorSet = new AnimatorSet(); animatorSet.PlayTogether(scaleXAnimator, scaleYAnimator, alphaAnimator); animatorSet.SetDuration(500); animatorSet.SetInterpolator(new DecelerateInterpolator(2)); animatorSet.Start(); }
public override View GetView(Context context, View convertView, ViewGroup parent) { this.Click = delegate { SelectImage(); }; Bitmap scaledBitmap = Bitmap.CreateScaledBitmap(_image, dimx, dimy, true); var view = convertView as RelativeLayout; if (view == null) { view = new RelativeLayout(context); _imageView = new ImageView(context); } else { _imageView = (ImageView)view.GetChildAt(0); } _imageView.SetImageBitmap(scaledBitmap); var parms = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent); parms.SetMargins(5, 2, 5, 2); parms.AddRule(LayoutRules.AlignParentLeft); if (_imageView.Parent != null && _imageView.Parent is ViewGroup) { ((ViewGroup)_imageView.Parent).RemoveView(_imageView); } view.AddView(_imageView, parms); return(view); }
//int height, oldX, oldY, X, Y; protected override void OnCreate(Bundle bundle) { base.OnCreate (bundle); SetContentView (Resource.Layout.card_table); group = (ViewGroup)FindViewById (Resource.Id.Main); ivBottom = FindViewById<ImageView> (Resource.Id.ivBottom); ivRight = FindViewById<ImageView> (Resource.Id.ivRight); ivTop = FindViewById<ImageView> (Resource.Id.ivTop); ivLeft = FindViewById<ImageView> (Resource.Id.ivLeft); lp = (RelativeLayout.LayoutParams)ivBottom.LayoutParameters; layoutParams = new RelativeLayout.LayoutParams (lp.Width, lp.Height); image = new ImageView (this); RunOnUiThread (() => { image.SetBackgroundResource (Resource.Drawable.blank_small); image.SetImageResource (Resource.Drawable.back); //image.Click += Remove_OnTouch; image.SetOnTouchListener (this); image.LayoutParameters = layoutParams; group.AddView (image); }); MyAnimationListener.AnimationEnded += AnimationEndedHandler; Deck deck = new Deck (0); cards = deck.ShuffledStack; //card = cards.Pop (); }
public override View GetView(Context context, View convertView, ViewGroup parent) { var view = convertView as RelativeLayout; if (view == null) view = new RelativeLayout(context); var parms = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent); parms.SetMargins(5, 3, 5, 0); parms.AddRule((int) LayoutRules.AlignParentLeft); _caption = new TextView(context) {Text = Caption, TextSize = 16f}; view.AddView(_caption, parms); if (!string.IsNullOrEmpty(Value)) { var tparms = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent); tparms.SetMargins(5, 3, 5, 0); tparms.AddRule((int) LayoutRules.AlignParentRight); _text = new TextView(context) {Text = Value, TextSize = 16f}; view.AddView(_text, tparms); } return view; }
private void RefreshEditButton() { if (iEditButton != null) { iDetailContainer.RemoveView(iEditButton); iEditButton.Click -= EditButtonClickHandler; iEditButton.Dispose(); } LayoutInflater inflater = (LayoutInflater)Context.GetSystemService(Context.LayoutInflaterService); iEditButton = BackButtonLayoutId == kNoButtonLayoutId ? new ToggleButton(Context) : inflater.Inflate(EditButtonLayoutId, null) as ToggleButton; iEditButton.TextOn = "Done"; iEditButton.TextOff = "Edit"; iEditButton.Id = kEditButtonId; iEditButton.Click += EditButtonClickHandler; iEditButton.Visibility = iEditMode ? ViewStates.Visible : ViewStates.Gone; RelativeLayout.LayoutParams buttonLayoutParams = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WrapContent, RelativeLayout.LayoutParams.WrapContent); buttonLayoutParams.AddRule(LayoutRules.AlignParentRight); buttonLayoutParams.AddRule(LayoutRules.AlignParentTop); buttonLayoutParams.BottomMargin = 10; iEditButton.LayoutParameters = buttonLayoutParams; iDetailContainer.AddView(iEditButton); }
public void OnSurfaceTextureAvailable(SurfaceTexture surface, int width, int height) { nn_surface = new Surface (surface); RelativeLayout.LayoutParams l; DisplayMetrics metrics = new DisplayMetrics(); nn_activity.WindowManager.DefaultDisplay.GetMetrics(metrics); l = new RelativeLayout.LayoutParams(metrics.HeightPixels, metrics.WidthPixels); l.AddRule(LayoutRules.CenterInParent); float scale = (metrics.HeightPixels * 1.0f) / (metrics.WidthPixels * 1.0f); textureview.ScaleX = scale; textureview.LayoutParameters=l; try { nn_mediaplayer= new MediaPlayer(); //String uriPath = "android.resource://"+nn_activity.PackageName+"/raw/Tap5050_About"; nn_mediaplayer.SetDataSource(nn_activity,global::Android.Net.Uri.Parse("android.resource://"+nn_activity.PackageName +"/"+ Resource.Raw.Tap5050_About)); nn_mediaplayer.SetSurface(nn_surface); nn_mediaplayer.Prepare(); nn_mediaplayer.Prepared+= (object sender, EventArgs e) => { (sender as MediaPlayer).Start (); }; nn_mediaplayer.Completion+= (object sender, EventArgs e) => { (sender as MediaPlayer).SeekTo (0); (sender as MediaPlayer).Pause (); }; }catch(Exception e){ Toast.MakeText (nn_activity,"Sorry,Can not play the video",ToastLength.Long).Show(); } }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); // Create your application here var rl = new RelativeLayout(this); _layoutParamsPortrait = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.FillParent, ViewGroup.LayoutParams.WrapContent); _layoutParamsLandscape = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.FillParent, ViewGroup.LayoutParams.WrapContent); _layoutParamsLandscape.LeftMargin = _layoutParamsLandscape.TopMargin = 150; _textView = new TextView(this); var surfaceOrientation = WindowManager.DefaultDisplay.Rotation; if (surfaceOrientation == SurfaceOrientation.Rotation0 || surfaceOrientation == SurfaceOrientation.Rotation180) { _textView.LayoutParameters = _layoutParamsPortrait; } else { _textView.LayoutParameters = _layoutParamsLandscape; } _textView.Text = "Programatic layout 4"; rl.AddView(_textView); SetContentView(rl); }
public static void showPopupWon(GameState gameState) { RelativeLayout popupContainer = (RelativeLayout)Shared.Activity.FindViewById(Resource.Id.popup_container); popupContainer.RemoveAllViews(); // popup PopupWonView popupWonView = new PopupWonView(Application.Context); popupWonView.SetGameState(gameState); int width = Application.Context.Resources.GetDimensionPixelSize(Resource.Dimension.popup_won_width); int height = Application.Context.Resources.GetDimensionPixelSize(Resource.Dimension.popup_won_height); RelativeLayout.LayoutParams relparams = new RelativeLayout.LayoutParams(width, height); relparams.AddRule(LayoutRules.CenterInParent); popupContainer.AddView(popupWonView, relparams); // animate all together ObjectAnimator scaleXAnimator = ObjectAnimator.OfFloat(popupWonView, "scaleX", 0f, 1f); ObjectAnimator scaleYAnimator = ObjectAnimator.OfFloat(popupWonView, "scaleY", 0f, 1f); AnimatorSet animatorSet = new AnimatorSet(); animatorSet.PlayTogether(scaleXAnimator, scaleYAnimator); animatorSet.SetDuration(500); animatorSet.SetInterpolator(new DecelerateInterpolator(2)); popupWonView.SetLayerType(LayerType.Hardware, null); animatorSet.Start(); }
public void AddtoView(RelativeLayout Root) { RelativeLayout.LayoutParams params1 = new RelativeLayout.LayoutParams(RtGraphicsLayouts.ConvertPxDp(120), RtGraphicsLayouts.ConvertPxDp(120)); params1.TopMargin = ((int)(RtGraphicsLayouts.ConvertPxDp(1800) * YNorm)) - RtGraphicsLayouts.ConvertPxDp(120); params1.LeftMargin = ((int)(RtGraphicsLayouts.ConvertPxDp(1800) * XNorm)) - RtGraphicsLayouts.ConvertPxDp(60); Root.AddView(_MarkerView, params1); }
public AvatarProgressRelativeLayout(Context context,int width,int progresswidth,int stokewidth,float percent) : base(context) { nn_context = context; nn_paint = new Paint (); nn_paint.AntiAlias = true; nn_outcolor = context.Resources.GetColor (Resource.Color.soarnix_bg_gray); nn_progressremainingcolor = Color.WhiteSmoke; nn_innercontainercolor = Color.White; nn_progresscolor = context.Resources.GetColor (Resource.Color.iosblue); nn_radius = TapUtil.dptodx(width)/2; this.stokewidthdp = stokewidth; this.progresswidthdp = progresswidth; progresssendangle =360 * percent; RelativeLayout.LayoutParams layoutparam=new RelativeLayout.LayoutParams (nn_radius*2,nn_radius*2); layoutparam.AddRule (LayoutRules.CenterInParent); this.LayoutParameters = layoutparam; SetLayerType (LayerType.Software,null); SetWillNotDraw(false); }
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { RelativeLayout mediarelativelayout =new RelativeLayout(nn_activity); var mediarelativelayoutparam=new RelativeLayout.LayoutParams (RelativeLayout.LayoutParams.MatchParent,RelativeLayout.LayoutParams.MatchParent); mediarelativelayout.LayoutParameters = mediarelativelayoutparam; mediarelativelayout.SetBackgroundColor (Color.White); Button playbut = new Button (nn_activity); RelativeLayout.LayoutParams playbutparam=new RelativeLayout.LayoutParams (RelativeLayout.LayoutParams.MatchParent,RelativeLayout.LayoutParams.MatchParent); playbut.Alpha = 0; playbutparam.AddRule(LayoutRules.CenterInParent); playbut.LayoutParameters = playbutparam; playbut.Click -=OntouchVideoView; playbut.Click += OntouchVideoView; mediarelativelayout.AddView (playbut); textureview = new TextureView (nn_activity); textureview.LayoutParameters = new RelativeLayout.LayoutParams (RelativeLayout.LayoutParams.MatchParent, RelativeLayout.LayoutParams.MatchParent); textureview.Rotation = 90; textureview.SurfaceTextureListener = this; mediarelativelayout.AddView (textureview); return mediarelativelayout; }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); Xamarin.Essentials.Platform.Init(this, savedInstanceState); if (savedInstanceState != null) { SupportActionBar.Title = savedInstanceState.GetString("LLAVE_GUARDADA"); } // Set our view from the "main" layout resource SetContentView(Resource.Layout.activity_main); RelativeLayout relativeLayout = FindViewById <RelativeLayout>(Resource.Id.relativeLayout); ColorButton myColorButton = new ColorButton(this); myColorButton.Text = "My Color Button"; myColorButton.Id = 100; RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WrapContent, RelativeLayout.LayoutParams.WrapContent); layoutParams.AddRule(LayoutRules.Below, Resource.Id.linearPersonalizado); myColorButton.LayoutParameters = layoutParams; relativeLayout.AddView(myColorButton); LayoutPersonalizado linearPersonalizado = new LayoutPersonalizado(this); RelativeLayout.LayoutParams layoutParams2 = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WrapContent, RelativeLayout.LayoutParams.WrapContent); layoutParams2.AddRule(LayoutRules.Below, Resource.Id.linearPersonalizado); linearPersonalizado.LayoutParameters = layoutParams2; relativeLayout.AddView(linearPersonalizado); }
public TabularAddButton(Context context) : base(context) { RelativeLayout.LayoutParams paramsForHolder = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MatchParent, RelativeLayout.LayoutParams.WrapContent); LayoutParameters = paramsForHolder; TextView AddText = new TextView(context); ImageButton Addbutton = new ImageButton(context); AddText.SetPadding(10, 10, 10, 10); AddText.Text = "Add"; AddText.SetTextAppearance(context, Resource.Style.TextAppearance_AppCompat_Medium); AddText.SetTextColor(Color.ParseColor("#27AE60")); Addbutton.SetBackgroundResource(Resource.Drawable.addbutton); RelativeLayout.LayoutParams paramsForAddText = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WrapContent, RelativeLayout.LayoutParams.WrapContent); paramsForAddText.AddRule(LayoutRules.AlignParentTop); paramsForAddText.AddRule(LayoutRules.AlignParentStart); AddText.LayoutParameters = paramsForAddText; //causes layout update RelativeLayout.LayoutParams paramsForAddButton = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WrapContent, RelativeLayout.LayoutParams.WrapContent); paramsForAddButton.AddRule(LayoutRules.CenterVertical); paramsForAddButton.AddRule(LayoutRules.AlignParentEnd); Addbutton.LayoutParameters = paramsForAddButton; //causes layout update AddView(AddText); AddView(Addbutton); }
public static void MatchParent(this View view) { var parent = ViewGroup.LayoutParams.MatchParent; var parameters = new RelativeLayout.LayoutParams(parent, parent); view.LayoutParameters = parameters; }
protected override void OnCreate (Bundle bundle) { base.OnCreate (bundle); _timestamp = DateTime.Now.ToLongTimeString (); // create a layout var rl = new RelativeLayout (this); var layoutParams = new RelativeLayout.LayoutParams (ViewGroup.LayoutParams.FillParent, ViewGroup.LayoutParams.FillParent); rl.LayoutParameters = layoutParams; // get the initial orientation var surfaceOrientation = this.WindowManager.DefaultDisplay.Rotation; // create the portrait and landscape layout _layoutParamsPortrait = new RelativeLayout.LayoutParams (ViewGroup.LayoutParams.FillParent, ViewGroup.LayoutParams.WrapContent); _layoutParamsLandscape = new RelativeLayout.LayoutParams (ViewGroup.LayoutParams.FillParent, ViewGroup.LayoutParams.WrapContent); _layoutParamsLandscape.LeftMargin = 100; _layoutParamsLandscape.TopMargin = 100; // create the TextView an assign the initial layout params _tv = new TextView (this); if (surfaceOrientation == SurfaceOrientation.Rotation0 || surfaceOrientation == SurfaceOrientation.Rotation180) { _tv.LayoutParameters = _layoutParamsPortrait; } else { _tv.LayoutParameters = _layoutParamsLandscape; } _tv.Text = "Programmatic layout. Timestamp = " + _timestamp; rl.AddView (_tv); SetContentView (rl); }
/// <summary> /// Used for selected imageView Dragging Event /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void generateView_Touch(object sender, View.TouchEventArgs e) { try { ImageView iv = (ImageView)sender; int X = (int)e.Event.RawX; int Y = (int)e.Event.RawY; switch (e.Event.Action) { case MotionEventActions.Down: /* Getting the current position of the imageview on the relative layout */ RelativeLayout.LayoutParams lParams = (RelativeLayout.LayoutParams)(((View)sender)).LayoutParameters; _xDelta = X - lParams.LeftMargin; _yDelta = Y - lParams.TopMargin; break; case MotionEventActions.Move: /* Getting the position on draggin the imageview and set into Relative layout */ RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams)(((View)sender)).LayoutParameters; layoutParams.LeftMargin = X - _xDelta; layoutParams.TopMargin = Y - _yDelta; layoutParams.RightMargin = -250; layoutParams.BottomMargin = -250; (((View)sender)).LayoutParameters = layoutParams; break; case MotionEventActions.Up: /* To activate click event for imageview */ iv.PerformClick(); break; } } catch (Exception ex) { } }
public BasicPackageManagerView(Context context) : base(context, Resource.Drawable.icon_menu_round) { // Initialize & style Status label StatusLabel = new TextView(context); StatusLabel.SetTextColor(Color.Black); GradientDrawable background = new GradientDrawable(); background.SetCornerRadius(5); background.SetColor(Color.Argb(160, 255, 255, 255)); StatusLabel.Background = background; StatusLabel.Gravity = Android.Views.GravityFlags.Center; StatusLabel.Typeface = Typeface.Create("HelveticaNeue", TypefaceStyle.Normal); DisplayMetrics screen = Resources.DisplayMetrics; int width = screen.WidthPixels / 2; int height = width / 4; int x = screen.WidthPixels / 2 - width / 2; int y = screen.HeightPixels / 100; var parameters = new RelativeLayout.LayoutParams(width, height); parameters.TopMargin = y; parameters.LeftMargin = x; AddView(StatusLabel, parameters); Menu = new CityChoiceMenu(context); AddView(Menu); }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); // create a layout var rl = new RelativeLayout(this); // set layout parameters var layoutParams = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.FillParent, ViewGroup.LayoutParams.FillParent); rl.LayoutParameters = layoutParams; // create TextView control var tv = new TextView(this); // set TextView's LayoutParameters tv.LayoutParameters = layoutParams; tv.Text = "Programmatic Orientation"; // add TextView to the layout rl.AddView(tv); // set the layout as the content view SetContentView(rl); }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); // Set our view from the "main" layout resource SetContentView(Resource.Layout.Main); _myLabel = FindViewById <TextView>(Resource.Id.FirstNameLabel); _myText = FindViewById <EditText>(Resource.Id.FirstNameBox); _landscapeParameters = new RelativeLayout.LayoutParams( _myText.LayoutParameters); _landscapeParameters.LeftMargin = 15; _landscapeParameters.RightMargin = 15; _landscapeParameters.AddRule( LayoutRules.RightOf, _myLabel.Id); _portraitParameters = new RelativeLayout.LayoutParams( _myText.LayoutParameters); _portraitParameters.LeftMargin = 15; _portraitParameters.RightMargin = 15; _portraitParameters.AddRule( LayoutRules.Below, _myLabel.Id); }
private void AttachSubscriberView(Subscriber subscriber) { RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(Resources.DisplayMetrics.WidthPixels, Resources.DisplayMetrics.HeightPixels); mSubscriberViewContainer.RemoveView(mSubscriber.View); mSubscriberViewContainer.AddView(mSubscriber.View, layoutParams); subscriber.SetStyle(BaseVideoRenderer.StyleVideoScale, BaseVideoRenderer.StyleVideoFill); }
public void AddSpinner(ViewGroup rootview,string loadingtext) { loading = true; if(loadingcontainer==null||(loadingcontainer!=null&&!loadingcontainer.IsShown)){ loadingcontainer = new RelativeLayout (nn_activity); loadingcontainer.LayoutParameters = new RelativeLayout.LayoutParams (RelativeLayout.LayoutParams.MatchParent, RelativeLayout.LayoutParams.MatchParent); loadingcontainer.SetBackgroundColor (Color.White); var detailcontainer = new LinearLayout (nn_activity); detailcontainer.Orientation = Orientation.Vertical; RelativeLayout.LayoutParams param = new RelativeLayout.LayoutParams ((int)TapUtil.dptodx (100), RelativeLayout.LayoutParams.WrapContent); param.AddRule (LayoutRules.CenterInParent); detailcontainer.LayoutParameters = param; LinearLayout.LayoutParams linearlayoutparm = new LinearLayout.LayoutParams (LinearLayout.LayoutParams.MatchParent, LinearLayout.LayoutParams.WrapContent); linearlayoutparm.Gravity = GravityFlags.CenterHorizontal; ProgressBar progressbar = new ProgressBar (nn_activity); progressbar.LayoutParameters = linearlayoutparm; TextView tectview = new TextView (nn_activity); tectview.LayoutParameters = linearlayoutparm; tectview.Text = loadingtext; tectview.Gravity = GravityFlags.CenterHorizontal; detailcontainer.AddView (progressbar); detailcontainer.AddView (tectview); loadingcontainer.AddView (detailcontainer); rootview.AddView (loadingcontainer); } }
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedState) { base.OnCreateView(inflater, container, savedState); View view = this.BindingInflate(Resource.Layout.commissions_overlay_layout, null); bool showIcon = this.Arguments.GetBoolean(IconBundleKey); string message = this.Arguments.GetString(MessageBundleKey); string title = this.Arguments.GetString(TitleBundleKey); if (string.IsNullOrEmpty(title) && !showIcon) { TextView messageTextView = view.FindViewById <TextView>(Resource.Id.status_message); RelativeLayout.LayoutParams layoutParams = messageTextView.LayoutParameters as RelativeLayout.LayoutParams; if (layoutParams != null) { layoutParams.AddRule(LayoutRules.CenterInParent); messageTextView.LayoutParameters = layoutParams; } } InfoViewModel vm = new InfoViewModel { HasIcon = showIcon, Message = message, Title = title }; this.ViewModel = vm; // App trackking GoogleAnalyticService.Instance.TrackScreen("Commissions Information"); return(view); }
public static ViewGroup.MarginLayoutParams WithMargins(this ViewGroup.MarginLayoutParams self, int?left, int?top, int?right, int?bottom) { var actualTop = top ?? self.TopMargin; var actualLeft = left ?? self.LeftMargin; var actualRight = right ?? self.RightMargin; var actualBottom = bottom ?? self.BottomMargin; switch (self) { case LinearLayout.LayoutParams linearParams: var newLinearLayoutParams = new LinearLayout.LayoutParams(self); newLinearLayoutParams.SetMargins(actualLeft, actualTop, actualRight, actualBottom); return(newLinearLayoutParams); case RelativeLayout.LayoutParams relativeParams: var newRelativeLayoutParams = new RelativeLayout.LayoutParams(self); newRelativeLayoutParams.SetMargins(actualLeft, actualTop, actualRight, actualBottom); return(newRelativeLayoutParams); case FrameLayout.LayoutParams frameParams: var newFrameLayoutParams = new FrameLayout.LayoutParams(self); newFrameLayoutParams.SetMargins(actualLeft, actualTop, actualRight, actualBottom); return(newFrameLayoutParams); case RecyclerView.LayoutParams recyclerParams: var newRecyclerParams = new FrameLayout.LayoutParams(self); newRecyclerParams.SetMargins(actualLeft, actualTop, actualRight, actualBottom); return(newRecyclerParams); } return(null); }
internal void UpdatePicture(string imgData, List <Dictionary <string, object> > coordIndexList) { var picture = BinaryToBitmap(imgData); if (picture != null) { image.SetImageBitmap(picture); } if (coordIndexList == null && coordIndexList.Count == 0) { return; } for (int i = 0; i < coordIndexList.Count; i++) { var x = Convert.ToInt32(coordIndexList[i]["X"]); var y = Convert.ToInt32(coordIndexList[i]["Y"]); var control = new Button(zoomLayout.Context); var param = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent); param.SetMargins(x, y, 0, 0); param.Width = DpToPx(30, this.Context); param.Height = DpToPx(30, this.Context); control.LayoutParameters = param; control.SetBackgroundColor(Color.Black); control.Text = coordIndexList[i]["Index"].ToString(); control.SetTextColor(Color.White); zoomLayout.AddView(control); } }
public TabularItemButton(Context context) : base(context) { RelativeLayout.LayoutParams paramsForHolder = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MatchParent, RelativeLayout.LayoutParams.WrapContent); LayoutParameters = paramsForHolder; TextView NameText = new TextView(context); TextView numberText = new TextView(context); NameText.SetTextAppearance(context, Resource.Style.TextAppearance_AppCompat_Medium); NameText.SetTextColor(Color.ParseColor("#000000")); NameText.SetPadding(10, 10, 10, 10); RelativeLayout.LayoutParams paramsForNameText = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WrapContent, RelativeLayout.LayoutParams.WrapContent); paramsForNameText.AddRule(LayoutRules.AlignParentTop); paramsForNameText.AddRule(LayoutRules.AlignParentStart); NameText.LayoutParameters = paramsForNameText; //causes layout update numberText.SetTextAppearance(context, Resource.Style.TextAppearance_AppCompat_Medium); numberText.SetTextColor(Color.ParseColor("#ffffff")); numberText.SetBackgroundColor(Color.ParseColor("#8f8e94")); numberText.SetBackgroundResource(Resource.Drawable.tabularcount); numberText.SetPadding(7, 0, 7, 0); numberText.Gravity = GravityFlags.Center; RelativeLayout.LayoutParams paramsFornumberText = new RelativeLayout.LayoutParams(70, RelativeLayout.LayoutParams.WrapContent); paramsFornumberText.AddRule(LayoutRules.AlignParentEnd); paramsFornumberText.AddRule(LayoutRules.CenterVertical); paramsFornumberText.SetMargins(0, 0, 30, 0); numberText.LayoutParameters = paramsFornumberText; //causes layout update AddView(NameText); AddView(numberText); }
void InitPopupMenu() { int layoutWidth = (Resources.DisplayMetrics.WidthPixels * 31) / 100; int layoutHeight = 4 * ((int)Resources.GetDimension(Resource.Dimension.main_menu_icon_size) + 2); RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(layoutWidth, layoutHeight); lp.AddRule(LayoutRules.Below, myActionBar.Id); lp.TopMargin = (int)Resources.GetDimension(Resource.Dimension.action_bar_height); RelativeLayout popupMenu = this.FindViewById <RelativeLayout>(Resource.Id.popup_mainmenu_inner); Log.Debug("MainMenu InitPopupMenu", "popupMenu=" + (popupMenu != null)); popupMenu.LayoutParameters = lp; popupMenu.SetBackgroundResource(Resource.Drawable.actionbar_background); MainMenuFragment mainmenupopup_fragment = (MainMenuFragment)SupportFragmentManager.FindFragmentById(Resource.Id.mainmenupopup_fragment); mainmenupopup_fragment.IsPopupMenu = true; Button btnSettings = this.FindViewById <Button>(Resource.Id.btnSettingsMain); btnSettings.Touch += (object sender, View.TouchEventArgs e) => { switch (e.Event.Action & MotionEventActions.Mask) { case MotionEventActions.Up: popupMenu.Visibility = ViewStates.Gone; SettingsClicked(); break; } }; }
public static void SetRelativeLayoutRule(this View view, Context context, LayoutRules rule, int anchor) { RelativeLayout.LayoutParams parameters = new RelativeLayout.LayoutParams((RelativeLayout.LayoutParams)view.LayoutParameters); parameters.AddRule(rule, anchor); view.LayoutParameters = parameters; view.RequestLayout(); }
public override View GetView(Context context, View convertView, ViewGroup parent) { this.Click = delegate { SelectImage(); }; Bitmap scaledBitmap = Bitmap.CreateScaledBitmap(_image, dimx, dimy, true); var view = convertView as RelativeLayout; if (view == null) { view = new RelativeLayout(context); _imageView = new ImageView(context); } else { _imageView = (ImageView)view.GetChildAt(0); } _imageView.SetImageBitmap(scaledBitmap); var parms = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent); parms.SetMargins(5, 2, 5, 2); parms.AddRule( LayoutRules.AlignParentLeft); if(_imageView.Parent != null && _imageView.Parent is ViewGroup) ((ViewGroup)_imageView.Parent).RemoveView(_imageView); view.AddView(_imageView, parms); return view; }
public static RelativeLayout.LayoutParams GetRelative (int x, int y, int w, int h) { RelativeLayout.LayoutParams parameters = new RelativeLayout.LayoutParams(w, h); parameters.LeftMargin = x; parameters.TopMargin = y; return parameters; }
public HSVColorPickerDialog(Context context, Color initialColor, Action<Color> listener) : base(context) { this.selectedColor = initialColor; this.listener = listener; colorWheel = new HSVColorWheel(context); valueSlider = new HSVValueSlider(context); var padding = (int)(context.Resources.DisplayMetrics.Density * PADDING_DP); var borderSize = (int)(context.Resources.DisplayMetrics.Density * BORDER_DP); var layout = new RelativeLayout(context); var lp = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MatchParent, RelativeLayout.LayoutParams.MatchParent); lp.BottomMargin = (int)(context.Resources.DisplayMetrics.Density * CONTROL_SPACING_DP); colorWheel.setListener((color) => valueSlider.SetColor(color, true)); colorWheel.setColor(initialColor); colorWheel.Id = (1); layout.AddView(colorWheel, lp); int selectedColorHeight = (int)(context.Resources.DisplayMetrics.Density * SELECTED_COLOR_HEIGHT_DP); var valueSliderBorder = new FrameLayout(context); valueSliderBorder.SetBackgroundColor(BORDER_COLOR); valueSliderBorder.SetPadding(borderSize, borderSize, borderSize, borderSize); valueSliderBorder.Id = (2); lp = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MatchParent, selectedColorHeight + 2 * borderSize); lp.BottomMargin = (int)(context.Resources.DisplayMetrics.Density * CONTROL_SPACING_DP); lp.AddRule(LayoutRules.Below, 1); layout.AddView(valueSliderBorder, lp); valueSlider.SetColor(initialColor, false); valueSlider.SetListener((color) => { selectedColor = color; selectedColorView.SetBackgroundColor(color); }); valueSliderBorder.AddView(valueSlider); var selectedColorborder = new FrameLayout(context); selectedColorborder.SetBackgroundColor(BORDER_COLOR); lp = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MatchParent, selectedColorHeight + 2 * borderSize); selectedColorborder.SetPadding(borderSize, borderSize, borderSize, borderSize); lp.AddRule(LayoutRules.Below, 2); layout.AddView(selectedColorborder, lp); selectedColorView = new View(context); selectedColorView.SetBackgroundColor(selectedColor); selectedColorborder.AddView(selectedColorView); SetButton((int)DialogButtonType.Negative, context.GetString(Android.Resource.String.Cancel), ClickListener); SetButton((int)DialogButtonType.Positive, context.GetString(Android.Resource.String.Ok), ClickListener); SetView(layout, padding, padding, padding, padding); }
// Delay creation of static edit text to last moment when we are sure to be in Android UI thread. // -> some Android phones crashes when native edit text is created from another thread than OS UI thread. private void EnsureStaticEditText() { if (staticEditText == null) { // create and add the edit text staticEditText = new MyAndroidEditText(PlatformAndroid.Context); var editLayoutParams = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.WrapContent); editLayoutParams.SetMargins(75, 200, 75, 0); GetGameContext().EditTextLayout.AddView(staticEditText, editLayoutParams); } }
public override View GetView (Context context, View convertView, ViewGroup parent) { TextView tv = new TextView (context); tv.TextSize = 20f; tv.SetText (Android.Text.Html.FromHtml (Caption), TextView.BufferType.Spannable); var parms = new RelativeLayout.LayoutParams (ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent); parms.AddRule (LayoutRules.CenterHorizontal); RelativeLayout view = new RelativeLayout (context, null, Android.Resource.Attribute.ListSeparatorTextViewStyle); view.AddView (tv, parms); return view; }
public View CreateActionButton(int resourceId) { var layout = ActionBar.CustomView.FindViewById<RelativeLayout>(Resource.Id.customActionButton); _actionButton = LayoutInflater.Inflate(resourceId, null); var textView = _actionButton as TextView; if (textView != null) textView.SetTypeface(Rep.FontManager.Get(Font.Condensed), TypefaceStyle.Normal); var param = new RelativeLayout.LayoutParams( ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.MatchParent); param.AddRule(LayoutRules.CenterVertical); param.AddRule(LayoutRules.AlignParentRight); layout.AddView(_actionButton, param); return _actionButton; }
public override View GetView (Context context, View convertView, ViewGroup parent) { var view = convertView as RelativeLayout; if (view == null) view = new RelativeLayout(context); var parms = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent); parms.SetMargins(5, 2, 5, 2); parms.AddRule(LayoutRules.AlignParentLeft); view.AddView(scaled,parms); return view; }
private static void SetLayotParameters(ConversationMessage currentItem, ConversationMessageViewHolder vh) { RelativeLayout.LayoutParams parameters = new RelativeLayout.LayoutParams(LinearLayout.LayoutParams.WrapContent, LinearLayout.LayoutParams.WrapContent); if (currentItem.UserWasSender) { parameters.AddRule(LayoutRules.AlignParentLeft); parameters.SetMargins(5, 5, 30, 5); vh.MessageLayout.Background = ContextCompat.GetDrawable(Application.Context, Resource.Drawable.conversation_user_message_background_border); vh.MessageHeader.SetTextColor(Color.Black); vh.MessageContent.SetTextColor(Color.Black); } else { parameters.AddRule(LayoutRules.AlignParentRight); parameters.SetMargins(30, 5, 5, 5); vh.MessageLayout.Background = ContextCompat.GetDrawable(Application.Context, Resource.Drawable.conversation_sender_message_background_border); vh.MessageHeader.SetTextColor(Color.White); vh.MessageContent.SetTextColor(Color.White); } vh.MessageLayout.LayoutParameters = parameters; }
protected override void OnCreate(Bundle bundle) { base.OnCreate (bundle); SetContentView(Resource.Layout.touch); group = (ViewGroup)FindViewById(Resource.Id.root); image = new ImageView(this); image.SetImageResource(Resource.Drawable.androids);//set image(80x80px) image.SetOnTouchListener(this); startLayoutParams = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WrapContent, RelativeLayout.LayoutParams.WrapContent); startLayoutParams.LeftMargin = 50; startLayoutParams.TopMargin = 50; startLayoutParams.BottomMargin = -250; startLayoutParams.RightMargin = -250; image.LayoutParameters=startLayoutParams; group.AddView(image); }
private void addButton_Click(object sender, EventArgs e) { if (SelectedViewIndex != -1) ShowAll(); var view = LayoutInflater.Inflate(Resource.Layout.PageLayout, RelativeLayout, false); view.Touch += View_Touch; Views.Add(view); var textView = view.FindViewById<TextView>(Resource.Id.textViewContent); textView.Text = Views.Count + " fsdfsdfsdfsfs"; var layoutParameters = new RelativeLayout.LayoutParams((int)(RelativeLayout.Width*0.8), (int)(RelativeLayout.Height*0.8)) { LeftMargin = (int)(RelativeLayout.Width * 0.1), TopMargin = _addButton.Height + 50 * Views.Count }; RelativeLayout.AddView(view, layoutParameters); }
public static TextView CreateGameOverTextView() { TextView gameOverTextView = new TextView(_context); gameOverTextView.Text = "Game over"; gameOverTextView.TextSize = 48; gameOverTextView.SetTextColor(Color.White); RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent); layoutParams.SetMargins(ConvertDpToPixels(200), ConvertDpToPixels(150), 0, 0); gameOverTextView.LayoutParameters = layoutParams; gameOverTextView.BringToFront(); return gameOverTextView; }
public override View GetView(Context context, View convertView, ViewGroup parent) { if (scaled == null) scaled = Scale(Value); Click = delegate { SelectImage(); }; var view = convertView as RelativeLayout ?? new RelativeLayout(context); var parms = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent); parms.SetMargins(5, 2, 5, 2); parms.AddRule(LayoutRules.AlignParentLeft); // SEC bug fix, not yet submitted to Kenny. Getting exception "specified view already has a parent" if (scaled.Parent != view) view.AddView(scaled, parms); return view; }
protected override void OnCreate (Bundle bundle) { base.OnCreate (bundle); SetContentView (Resource.Layout.activity_banner_code_ad_listener); adView = new AdView (this) { AdUnitId = Resources.GetString (Resource.String.ad_unit_id), AdSize = AdSize.Banner, AdListener = new ToastAdListener (this) }; var layout = FindViewById<RelativeLayout> (Resource.Id.mainLayout); var lp = new RelativeLayout.LayoutParams ( ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.WrapContent); layout.AddView (adView, lp); adView.LoadAd (GoogleAdsSampleActivity.GetAdRequest (true)); }
public static ImageView CreateImageView(int drawableId, int marginLeft, int marginTop, int? id = null, int controlHeight = ViewGroup.LayoutParams.WrapContent) { ImageView imageView = new ImageView(_context); imageView.SetImageResource(drawableId); if (id != null) { imageView.Id = id.Value; } RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WrapContent, controlHeight); //margin values are in pixels layoutParams.SetMargins(marginLeft, marginTop, 0, 0); imageView.LayoutParameters = layoutParams; return imageView; }
public async Task AddNewShape (int maxHeight, int maxWidth) { var shape = await _shapeFactory.GeneralShapeRandom (maxHeight,maxWidth); ShapeBase shapeInfo; if (shape is CircleShape) shapeInfo = await _webService.GetShapeInforAsync (shape); else shapeInfo = shape; RelativeLayout.LayoutParams layoutParams= new RelativeLayout.LayoutParams (shapeInfo.Radius * 2, shapeInfo.Radius * 2); layoutParams.LeftMargin = shapeInfo.Center_X - shapeInfo.Radius; layoutParams.TopMargin = shapeInfo.Center_Y - shapeInfo.Radius; ShapeViewModel viewModel = new ShapeViewModel (shapeInfo); if (shapeInfo is CircleShape) { var circleView = new CirclesShapeView (_context, viewModel); _mainLayout.AddView (circleView,layoutParams); } if (shapeInfo is SquareShape) { var squareView = new SquareShapeView (_context, viewModel); _mainLayout.AddView (squareView, layoutParams); } }
private void InitTablet() { SetContentView(Resource.Layout.TabletContainer); var container = FindViewById<RelativeLayout>(Resource.Id.fragmentContainer); var blotterViewId = View.GenerateViewId(); var pricesView = PricesListFragment.OnCreateView(LayoutInflater, container, null); var pricesParams = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent); pricesParams.AddRule(LayoutRules.Above, blotterViewId); pricesView.LayoutParameters = pricesParams; pricesView.Id = View.GenerateViewId(); container.AddView(pricesView); var blotterView = BlotterFragment.OnCreateView(LayoutInflater, container, null); var layoutParams = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MatchParent, 280); blotterView.Id = blotterViewId; layoutParams.AddRule(LayoutRules.AlignParentBottom); blotterView.LayoutParameters = layoutParams; container.AddView(blotterView); }
public override View GetView(Context context, View convertView, ViewGroup parent) { var view = new RelativeLayout(context); var parms = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent); parms.SetMargins(5, 3, 5, 0); parms.AddRule((int) LayoutRules.CenterVertical); tv = new TextView(context) {Text = Caption, TextSize = 16f}; view.AddView(tv, parms); var sparms = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent); sparms.SetMargins(5, 3, 5, 0); sparms.AddRule((int) LayoutRules.CenterVertical); sparms.AddRule((int) LayoutRules.AlignParentRight); sw = new ToggleButton(context) {Tag = 1, Checked = Value}; view.AddView(sw, sparms); return view; }
public ToolBarButton(Context context,View parent,int imagresource) : base(context) { //initial params if(parent is LinearLayout){ LinearLayout.LayoutParams param=new LinearLayout.LayoutParams(TapUtil.dptodx(45),TapUtil.dptodx(45)); param.Weight = 1; LayoutParameters = param; } if (parent is RelativeLayout) { RelativeLayout.LayoutParams param=new RelativeLayout.LayoutParams(TapUtil.dptodx(45),TapUtil.dptodx(45)); LayoutParameters = param; } this.SetPadding (TapUtil.dptodx (1), TapUtil.dptodx (1), TapUtil.dptodx (1), TapUtil.dptodx (1)); //add child view ImageView img = new ImageView (context); img.Id = TapUtil.generateViewId (); RelativeLayout.LayoutParams paramimg=new RelativeLayout.LayoutParams(TapUtil.dptodx(40),TapUtil.dptodx(40)); paramimg.AddRule (LayoutRules.CenterHorizontal); img.LayoutParameters = paramimg; img.SetImageResource (imagresource); AddView (img); }
void Initialize () { BackgroundColor = Color.Black; strokeColor = Color.White; StrokeWidth = 2f; canvasView = new SignatureCanvasView (this.context); canvasView.LayoutParameters = new RelativeLayout.LayoutParams (RelativeLayout.LayoutParams.FillParent, RelativeLayout.LayoutParams.FillParent); //Set the attributes for painting the lines on the screen. paint = new Paint (); paint.Color = strokeColor; paint.StrokeWidth = StrokeWidth; paint.SetStyle (Paint.Style.Stroke); paint.StrokeJoin = Paint.Join.Round; paint.StrokeCap = Paint.Cap.Round; paint.AntiAlias = true; #region Add Subviews RelativeLayout.LayoutParams layout; BackgroundImageView = new ImageView (this.context); BackgroundImageView.Id = generateId (); AddView (BackgroundImageView); //Add an image that covers the entire signature view, used to display already drawn //elements instead of having to redraw them every time the user touches the screen. imageView = new ClearingImageView (context); imageView.SetBackgroundColor (Color.Transparent); imageView.LayoutParameters = new RelativeLayout.LayoutParams (RelativeLayout.LayoutParams.FillParent, RelativeLayout.LayoutParams.FillParent); AddView (imageView); lblSign = new TextView (context); lblSign.Id = generateId (); lblSign.SetIncludeFontPadding (true); lblSign.Text = "Sign Here"; layout = new RelativeLayout.LayoutParams (RelativeLayout.LayoutParams.WrapContent, RelativeLayout.LayoutParams.WrapContent); layout.AlignWithParent = true; layout.BottomMargin = 6; layout.AddRule (LayoutRules.AlignBottom); layout.AddRule (LayoutRules.CenterHorizontal); lblSign.LayoutParameters = layout; lblSign.SetPadding (0, 0, 0, 6); AddView (lblSign); //Display the base line for the user to sign on. signatureLine = new View (context); signatureLine.Id = generateId (); signatureLine.SetBackgroundColor (Color.Gray); layout = new RelativeLayout.LayoutParams (RelativeLayout.LayoutParams.MatchParent, 1); layout.SetMargins (10, 0, 10, 5); layout.AddRule (LayoutRules.Above, lblSign.Id); signatureLine.LayoutParameters = layout; AddView (signatureLine); //Display the X on the left hand side of the line where the user signs. xLabel = new TextView (context); xLabel.Id = generateId (); xLabel.Text = "X"; xLabel.SetTypeface (null, TypefaceStyle.Bold); layout = new RelativeLayout.LayoutParams (RelativeLayout.LayoutParams.WrapContent, RelativeLayout.LayoutParams.WrapContent); layout.LeftMargin = 11; layout.AddRule (LayoutRules.Above, signatureLine.Id); xLabel.LayoutParameters = layout; AddView (xLabel); AddView (canvasView); lblClear = new TextView (context); lblClear.Id = generateId (); lblClear.Text = "Clear"; layout = new RelativeLayout.LayoutParams (RelativeLayout.LayoutParams.WrapContent, RelativeLayout.LayoutParams.WrapContent); layout.SetMargins (0, 10, 22, 0); layout.AlignWithParent = true; layout.AddRule (LayoutRules.AlignRight); layout.AddRule (LayoutRules.AlignTop); lblClear.LayoutParameters = layout; lblClear.Visibility = ViewStates.Invisible; lblClear.Click += (object sender, EventArgs e) => { Clear (); }; AddView (lblClear); #endregion paths = new List<Path> (); points = new List<System.Drawing.PointF[]> (); currentPoints = new List<System.Drawing.PointF> (); dirtyRect = new RectF (); }
protected override void OnCreate(Bundle bundle) { base.OnCreate (bundle); //RequestedOrientation = global::Android.Content.PM.ScreenOrientation.Landscape; // Set our view from the "main" layout resource SetContentView (Resource.Layout.Main); SignaturePadView signature = FindViewById<SignaturePadView> (Resource.Id.signatureView); if (true) { // Customization activated View root = FindViewById<View> (Resource.Id.rootView); root.SetBackgroundColor (Color.White); // Activate this to internally use a bitmap to store the strokes // (good for frequent-redraw situations, bad for memory footprint) // signature.UseBitmapBuffer = true; signature.CaptionTextView.Text = "Authorization Signature"; signature.CaptionTextView.SetTypeface (Typeface.Serif, TypefaceStyle.BoldItalic); signature.CaptionTextView.SetTextSize (global::Android.Util.ComplexUnitType.Sp, 16f); signature.SignaturePromptTextView.Text = ">>"; signature.SignaturePromptTextView.SetTypeface (Typeface.SansSerif, TypefaceStyle.Normal); signature.SignaturePromptTextView.SetTextSize (global::Android.Util.ComplexUnitType.Sp, 32f); signature.BackgroundColor = Color.Rgb (255, 255, 200); // a light yellow. signature.StrokeColor = Color.Black; signature.BackgroundImageView.SetImageResource (Resource.Drawable.logo_galaxy_black_64); signature.BackgroundImageView.SetAlpha (16); signature.BackgroundImageView.SetAdjustViewBounds (true); var layout = new RelativeLayout.LayoutParams (RelativeLayout.LayoutParams.FillParent, RelativeLayout.LayoutParams.FillParent); layout.AddRule (LayoutRules.CenterInParent); layout.SetMargins (20, 20, 20, 20); signature.BackgroundImageView.LayoutParameters = layout; // You can change paddings for positioning... var caption = signature.CaptionTextView; caption.SetPadding (caption.PaddingLeft, 1, caption.PaddingRight, 25); } // Get our button from the layout resource, // and attach an event to it Button btnSave = FindViewById<Button> (Resource.Id.btnSave); btnSave.Click += delegate { if (signature.IsBlank) {//Display the base line for the user to sign on. AlertDialog.Builder alert = new AlertDialog.Builder (this); alert.SetMessage ("No signature to save."); alert.SetNeutralButton ("Okay", delegate { }); alert.Create ().Show (); } points = signature.Points; }; btnSave.Dispose (); Button btnLoad = FindViewById<Button> (Resource.Id.btnLoad); btnLoad.Click += delegate { if (points != null) signature.LoadPoints (points); }; btnLoad.Dispose (); }