public override View OnCreateView(LayoutInflater layoutInflater, ViewGroup viewGroup, Bundle bundle) { View view = layoutInflater.Inflate(Resource.Layout.fragment_onechoice_questionario, viewGroup, false); TextView textView = view.FindViewById <TextView>(Resource.Id.title_text_view); RadioGroup radioGroup = view.FindViewById <RadioGroup>(Resource.Id.options_group); LinearLayout linearLayout = view.FindViewById <LinearLayout>(Resource.Id.options_layout); textView.Text = _questao.getTitulo(); textView.Selected = true; int respostaSelected = QuestionarioManager.GetInstance().LastRespostaSelected(_page); List <Resposta> respostas = _questao.Respostas; for (int i = 0; i < _questao.Respostas.Count; i++) { int id = i; QuestionarioWidgetGenerator.CreateRadioButton(radioGroup, _page, id, respostas[i].Descricao, respostaSelected == id); } LinearLayout layout = view.FindViewById <LinearLayout>(Resource.Id.root_options_layout); EditNewRespostaLayout editNewRespostaLayout = new EditNewRespostaLayout(view.Context); LayoutParams lparams = new LayoutParams(-1, -2); lparams.SetMargins(14, 0, 0, 0); layout.AddView(editNewRespostaLayout, lparams); return(view); }
void Init() { //Inflate(Context, Resource.Layout.widget_square, this); //textView = FindViewById<TextView>(Resource.Id.text); //unfinishedBackground = FindViewById<View>(Resource.Id.unfinished_background); /* * * <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" * xmlns:tools="http://schemas.android.com/tools" * android:layout_width="match_parent" * android:layout_height="match_parent" * > * * <View * android:id="@+id/unfinished_background" * android:layout_width="match_parent" * android:layout_height="match_parent" * android:background="@color/game_unfinished_background" /> * * <TextView * android:id="@+id/text" * android:layout_width="wrap_content" * android:layout_height="wrap_content" * android:layout_gravity="center" * android:layout_margin="@dimen/margin_small" * android:fontFamily="sans-serif-light" * android:textAlignment="gravity" * android:textColor="@color/white" * android:textSize="@dimen/square_font_size" * tools:text="25" /> * * </FrameLayout> */ unfinishedBackground = new View(Context) { LayoutParameters = new LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent) }; unfinishedBackground.SetBackgroundColor(DefaultBackgroundColor); AddView(unfinishedBackground); var px = Resources.GetDimensionPixelSize(Resource.Dimension.margin_small); var layout = new LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent); textView = new TextView(Context) { Gravity = GravityFlags.Center, Typeface = DefaultTypeface, TextAlignment = TextAlignment.Gravity, LayoutParameters = layout }; layout.SetMargins(px, px, px, px); textView.SetTextColor(Color.White); textView.SetTextSize(ComplexUnitType.Px, Resources.GetDimensionPixelSize(Resource.Dimension.square_font_size)); AddView(textView); }
protected void AddFloatingActionButton () { var fabSize = Resources.GetDimensionPixelSize (Resource.Dimension.size_fab); var bottomOfQuestionView = FindViewById (Resource.Id.question_view).Bottom; var fabLayoutParams = new LayoutParams (fabSize, fabSize, GravityFlags.End | GravityFlags.Top); var halfAFab = fabSize / 2; fabLayoutParams.SetMargins (0, // left bottomOfQuestionView - halfAFab, //top 0, // right spacingDouble); // bottom fabLayoutParams.MarginEnd = spacingDouble; AddView (submitAnswer, fabLayoutParams); }
protected void AddFloatingActionButton() { var fabSize = Resources.GetDimensionPixelSize(Resource.Dimension.size_fab); var bottomOfQuestionView = FindViewById(Resource.Id.question_view).Bottom; var fabLayoutParams = new LayoutParams(fabSize, fabSize, GravityFlags.End | GravityFlags.Top); var halfAFab = fabSize / 2; fabLayoutParams.SetMargins(0, // left bottomOfQuestionView - halfAFab, //top 0, // right spacingDouble); // bottom fabLayoutParams.MarginEnd = spacingDouble; AddView(submitAnswer, fabLayoutParams); }
public void AddViews(List <Model.Player> myCurrentPlayers) { RemoveAllViews(); for (int i = 0; i < myCurrentPlayers.Count; i++) { var layoutParams = new LayoutParams(0, ViewGroup.LayoutParams.WrapContent, 1); layoutParams.SetMargins(15, 15, 15, 15); SquaredTextView newButton = new SquaredTextView(Context) { LayoutParameters = layoutParams, Text = myCurrentPlayers[i].FirstName }; AddView(newButton); } }
private void Init() { this.Clickable = true; timer = new System.Timers.Timer(BannerTimeout); gestureDetector = new Android.Support.V4.View.GestureDetectorCompat(Context, gestureListener = new SwipeGestureListener()); innerView = new CardView(Context); innerView.UseCompatPadding = true; Android.Support.V4.View.ViewCompat.SetElevation(innerView, 4.DpToPx()); innerView.Radius = 8.DpToPx(); var w = Android.App.Application.Context.Resources.DisplayMetrics.WidthPixels - 120; using (var prms = new LayoutParams(LayoutParams.WrapContent, LayoutParams.WrapContent)) { prms.Width = w; prms.SetMargins(10.DpToPx(), 40.DpToPx(), 10.DpToPx(), 0); this.AddView(innerView, prms); } var inflater = (LayoutInflater)Context.GetSystemService(Context.LayoutInflaterService); inflater.Inflate(Resource.Layout.banner_notification, innerView); Typeface tfMedium = Typeface.CreateFromAsset(Android.App.Application.Context.Assets, "Poppins-Medium.ttf"); Typeface tfNormal = Typeface.CreateFromAsset(Android.App.Application.Context.Assets, "Poppins-Regular.ttf"); try{ var title = innerView.FindViewById(Resource.Id.text_banner_title) as TextView; title.SetTypeface(tfMedium, TypefaceStyle.Normal); title.SetTextSize(Android.Util.ComplexUnitType.Dip, 14); var subtitle = innerView.FindViewById(Resource.Id.text_banner_subtitle) as TextView; subtitle.SetTypeface(tfNormal, TypefaceStyle.Normal); subtitle.SetTextSize(Android.Util.ComplexUnitType.Dip, 12); } catch (Exception ex) { Console.WriteLine(ex); } innerView.Visibility = ViewStates.Gone; }
public void Update(Type type, int position) { LayoutParams parameters = new LayoutParams(LayoutParams.WrapContent, LayoutParams.MatchParent); parameters.SetMargins(10, 10, 10, 10); title.Text = type.GetTitle(); title.LayoutParameters = parameters; ColorDrawable background; if (type.IsHeader()) { background = new ColorDrawable(Color.Black); if (position == 0) { topBorder.LayoutParameters = new LayoutParams(0, 0); } else { parameters = new LayoutParams(ViewGroup.LayoutParams.MatchParent, 15); topBorder.LayoutParameters = parameters; } description.Text = ""; description.LayoutParameters = new LayoutParams(0, 0); SetBackgroundColor(Color.Rgb(200, 200, 200)); } else { background = null; description.Text = type.GetDescription(); description.LayoutParameters = parameters; SetBackgroundColor(Color.Rgb(240, 240, 240)); } try { // API came with android 4.1 topBorder.Background = background; } catch { topBorder.SetBackgroundColor(Color.Black); } }
private void InitializeLayout() { for (int i = 0; i < imageList.Count; i++) { Bitmap bitmap = BitmapFactory.DecodeResource(Context.Resources, imageList[i]); Size optimalSize = CalculateOptimalSizeOfImage(bitmap.Width, bitmap.Height); LinearLayout.LayoutParams layoutParams = new LayoutParams((int)optimalSize.Width, (int)optimalSize.Height); layoutParams.SetMargins(0, 2, 0, 2); layoutParams.Gravity = GravityFlags.Center; ImageView imgView = new ImageView(Context); imgView.SetImageBitmap(bitmap); this.AddView(imgView, i); } LinearLayout.LayoutParams linearlayoutParams = new LinearLayout.LayoutParams(LayoutParams.MatchParent, LayoutParams.MatchParent); linearlayoutParams.Gravity = GravityFlags.Center; this.LayoutParameters = linearlayoutParams; }
private void InitCloseImage() { if (!_closable) { return; } var lParams = new LayoutParams((int)Resources.GetDimension(Resource.Dimension.chip_close_icon_size_medium), (int)Resources.GetDimension(Resource.Dimension.chip_close_icon_size_medium)); lParams.AddRule(Build.VERSION.SdkInt >= BuildVersionCodes.JellyBean ? LayoutRules.EndOf : LayoutRules.RightOf, ChipUtils.TEXT_ID); lParams.AddRule(LayoutRules.CenterVertical); lParams.SetMargins((int)Resources.GetDimension(Resource.Dimension.chip_close_horizontal_margin), 0, (int)Resources.GetDimension(Resource.Dimension.chip_close_horizontal_margin), 0); closeImageView.LayoutParameters = lParams; closeImageView.SetScaleType(ImageView.ScaleType.Center); closeImageView.SetImageDrawable(_closeIcon); ChipUtils.SetIconColor(closeImageView, _closeColor); InitCloseClick(); AddView(closeImageView); }
void Init() { SetClipChildren(false); var px = Resources.GetDimensionPixelSize(Resource.Dimension.piece_margin); highlightView = new View(Context) { LayoutParameters = new LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent) }; highlightView.SetBackgroundResource(Resource.Drawable.box); var markerLayout = new LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent); markerLayout.SetMargins(px, px, px, px); unfinishedMarker = new View(Context) { LayoutParameters = markerLayout }; unfinishedMarker.SetBackgroundResource(Resource.Color.game_unfinished_marker); px = Resources.GetDimensionPixelSize(Resource.Dimension.margin_small); var textLayout = new LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent); textLayout.SetMargins(px, px, px, px); textView = new TextView(Context) { Gravity = GravityFlags.Center, Typeface = DefaultTypeface, TextAlignment = TextAlignment.Gravity, LayoutParameters = textLayout }; textView.SetTextColor(Color.White); textView.SetTextSize(ComplexUnitType.Px, Resources.GetDimensionPixelSize(Resource.Dimension.cell_font_size)); textView.Visibility = ViewStates.Gone; AddView(highlightView); AddView(unfinishedMarker); AddView(textView); }
private void Initialize() { ImageView logo = new ImageView(Context) { Id = 0x0fffff2a }; logo.SetImageResource(Resource.Drawable.logo); logo.SetAdjustViewBounds(true); logo.SetMinimumHeight(60); logo.SetMaxHeight(60); _imageCategoryView = new ImageView(Context); _imageCategoryView.SetAdjustViewBounds(true); _imageCategoryView.SetMinimumHeight(60); _imageCategoryView.SetMaxHeight(60); _imageCategoryView.Id = 0x0fffff2b; _imageCategoryView.SetMinimumWidth(60); _imageCategoryView.SetMaxWidth(60); _imageCategoryView.Measure(60, 60); _textCategoryView = new TextView(Context); _textCategoryView.SetMaxHeight(60); _textCategoryView.SetTextColor(Color.Black); _textCategoryView.Id = 0x0fffff2c; _textCategoryView.SetTextSize(ComplexUnitType.Sp, 15); _textCategoryView.Gravity = GravityFlags.CenterVertical; LayoutParams lp = new LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent); lp.AddRule(LayoutRules.AlignParentRight); lp.AddRule(LayoutRules.CenterVertical); AddView(logo, lp); lp = new LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent); lp.AddRule(LayoutRules.AlignParentLeft); lp.AddRule(LayoutRules.CenterVertical); AddView(_imageCategoryView, lp); lp = new LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent); lp.AddRule(LayoutRules.RightOf, _imageCategoryView.Id); lp.AddRule(LayoutRules.CenterVertical); lp.SetMargins(60, 0, 60, 0); AddView(_textCategoryView, lp); }
public void validation() { linearLayout1.RemoveAllViews(); try { using (var client = new WebClient()) { string userID = Library.ControlID.userID; quizID = Library.ControlID.quizTitleID; var json = client.DownloadString("http://joremtongwebsite.000webhostapp.com/quizvalidation.php?userID=" + userID + "&&quizID=" + quizID); dynamic jsonData = JsonConvert.DeserializeObject(json); foreach (dynamic jsonDatas in jsonData) { var layout = new LinearLayout(this); layout.Orientation = Orientation.Vertical; LayoutParams layoutParams = new LayoutParams(LinearLayout.LayoutParams.MatchParent, LinearLayout.LayoutParams.WrapContent); layoutParams.SetMargins(5, 5, 5, 5); layout.SetBackgroundColor(Color.White); layout.SetPadding(0, 0, 0, 0); var username = new TextView(this); username.SetTextColor(Color.Red); username.SetTypeface(Typeface.Default, TypefaceStyle.BoldItalic); username.SetTextSize(global::Android.Util.ComplexUnitType.Dip, 20); username.Text = "Already Take This Exam"; username.SetPadding(20, 20, 20, 0); layout.AddView(username); linearLayout1.AddView(layout); } } } catch (Exception i) { list(); } }
public override void SetPlayers(List <Player> myCurrentPlayers) { int count = myCurrentPlayers.Count; int layoutCount = ChildCount; double doubleChild = Convert.ToDouble(count) / layoutCount; int childPerLayout = Convert.ToInt16(Math.Ceiling(doubleChild)); int playerIndex = 0; for (int child = 0; child < ChildCount; child++) { LinearLayout view = GetChildAt(child) as LinearLayout; view.RemoveAllViews(); for (int i = 0; i < childPerLayout; i++) { if (playerIndex >= count) { break; } var layoutParams = new LayoutParams(0, ViewGroup.LayoutParams.WrapContent, 1); layoutParams.SetMargins(15, 15, 15, 15); Player currentPlayer = myCurrentPlayers[playerIndex]; ItemHolderRadioButton newButton = new ItemHolderRadioButton(Context, true) { LayoutParameters = layoutParams, ItemId = currentPlayer.Id, Text = (currentPlayer.Number > -1 ? currentPlayer.Number + " " : "") + currentPlayer.FirstName, Id = GenerateViewId(), }; newButton.CheckedChange += Rb_CheckedChange; myButtons.Add(newButton); view.AddView(newButton); playerIndex++; } } }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.Game); strikes = 0; guessedLetters = new List <char>(); create_word(); FindViewById <Button>(Resource.Id.btnback).Click += btnback_Click;; char[] row1 = "qwertyuiop".ToCharArray(); char[] row2 = "asdfghjkl".ToCharArray(); char[] row3 = "zxcvbnm".ToCharArray(); char[][] rows = { row1, row2, row3 }; LinearLayout keyboard1 = FindViewById <LinearLayout>(Resource.Id.linKeyboard1); LinearLayout keyboard2 = FindViewById <LinearLayout>(Resource.Id.linKeyboard2); LinearLayout keyboard3 = FindViewById <LinearLayout>(Resource.Id.linKeyboard3); LinearLayout[] keyboards = { keyboard1, keyboard2, keyboard3 }; for (int row = 0; row < rows.Length; row++) { for (int letter = 0; letter < rows[row].Length; letter++) { var newButton = new Button(this); newButton.Click += onLetterPress; newButton.Text = rows[row][letter].ToString(); newButton.SetBackgroundColor(new Android.Graphics.Color(255, 225, 30)); //newButton.SetForegroundGravity(GravityFlags.Center); //newButton.SetPadding(50, 5, 50, 5); var layoutParams = new LayoutParams(80, ViewGroup.LayoutParams.MatchParent); layoutParams.SetMargins(10, 10, 10, 10); keyboards[row].AddView(newButton, layoutParams); } } }
public void listOfStudent() { linearLayout1.RemoveAllViews(); try { using (var client = new WebClient()) { string userID = Library.ControlID.userID; string id = Library.ControlID.userID; var json = client.DownloadString("http://joremtongwebsite.000webhostapp.com/studentHandoutList.php?userID=" + userID); dynamic jsonData = JsonConvert.DeserializeObject(json); foreach (dynamic jsonDatas in jsonData) { var layout2 = new LinearLayout(this); layout2.Orientation = Orientation.Horizontal; var layoutParams2 = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.WrapContent); layoutParams2.SetMargins(0, 0, 0, 20); layout2.SetBackgroundResource(Resource.Drawable.layout_bg); layout2.SetPadding(20, 20, 60, 20); layout2.LayoutParameters = layoutParams2; var Image = new ImageView(this); var param = new LayoutParams(150, 150); Image.LayoutParameters = param; Image.SetPadding(30, 40, 0, 0); Image.SetImageResource(Resource.Drawable.pdffile); var layout = new LinearLayout(this); layout.Orientation = Orientation.Vertical; var layoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.WrapContent); layoutParams.SetMargins(10, 0, 0, 20); layout.SetBackgroundResource(Resource.Drawable.layout_bg); layout.SetPadding(0, 0, 0, 0); layout.LayoutParameters = layoutParams; layout.Click += delegate { string url = "http://joremtongwebsite.000webhostapp.com/upload/" + jsonDatas["filename"].ToString(); if (!url.Contains("http://")) { string address = url; url = String.Format("http://(0)", address); } var uri = Android.Net.Uri.Parse(url); Intent intent = new Intent(Intent.ActionView, uri); StartActivity(intent); }; var username = new TextView(this); username.SetTextColor(Color.White); username.SetTypeface(Typeface.Default, TypefaceStyle.Bold); username.SetTextSize(global::Android.Util.ComplexUnitType.Dip, 24); username.Text = jsonDatas["title"].ToString(); username.SetPadding(0, 0, 0, 0); var filename = new TextView(this); filename.SetTextColor(Color.White); filename.SetTypeface(Typeface.Default, TypefaceStyle.Normal); filename.SetTextSize(global::Android.Util.ComplexUnitType.Dip, 15); filename.Text = jsonDatas["filename"].ToString(); filename.SetPadding(0, 0, 0, 0); var Title = new TextView(this); Title.SetTextColor(Color.DimGray); Title.SetTypeface(Typeface.Default, TypefaceStyle.Normal); Title.SetTextSize(global::Android.Util.ComplexUnitType.Dip, 15); Title.Text = jsonDatas["subject"].ToString(); Title.SetPadding(0, 0, 0, 0); layout.AddView(username); layout.AddView(filename); layout.AddView(Title); layout2.AddView(Image); layout2.AddView(layout); linearLayout1.AddView(layout2); } } } catch (Exception i) { var layout = new LinearLayout(this); layout.Orientation = Orientation.Vertical; LayoutParams layoutParams = new LayoutParams(LinearLayout.LayoutParams.MatchParent, LinearLayout.LayoutParams.WrapContent); layoutParams.SetMargins(5, 5, 5, 5); layout.SetBackgroundColor(Color.White); layout.SetPadding(0, 0, 0, 0); var username = new TextView(this); username.SetTextColor(Color.Red); username.SetTypeface(Typeface.Default, TypefaceStyle.BoldItalic); username.SetTextSize(global::Android.Util.ComplexUnitType.Dip, 20); username.Text = "NO DATA YET"; username.SetPadding(20, 20, 20, 0); layout.AddView(username); linearLayout1.AddView(layout); } }
public void SetupLayout(PdfView pdfView) { LayoutRules align; int width, height; Drawable background; // determine handler position, default is right (when scrolling vertically) or bottom (when scrolling horizontally) if (pdfView.IsSwipeVertical) { width = HandleLong; height = HandleShort; if (inverted) { // left align = LayoutRules.AlignParentLeft; background = Context.GetDrawable(Resource.Drawable.default_scroll_handle_left); } else { // right align = LayoutRules.AlignParentRight; background = Resources.GetDrawable(Resource.Drawable.default_scroll_handle_right); } } else { width = HandleShort; height = HandleLong; if (inverted) { // top align = LayoutRules.AlignParentTop; background = Context.GetDrawable(Resource.Drawable.default_scroll_handle_top); } else { // bottom align = LayoutRules.AlignParentBottom; background = Context.GetDrawable(Resource.Drawable.default_scroll_handle_bottom); } } if (Build.VERSION.SdkInt < BuildVersionCodes.JellyBean) { SetBackgroundDrawable(background); } else { Background = background; } var lp = new LayoutParams(Util.Util.GetDp(context, width), Util.Util.GetDp(context, height)); lp.SetMargins(0, 0, 0, 0); var tvlp = new LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent); tvlp.AddRule(LayoutRules.CenterInParent); AddView(textView, tvlp); lp.AddRule(align); pdfView.AddView(this, lp); this.pdfView = pdfView; }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); int margin = Utils.DpToPx(0.02f * Utils.DisplayMetrics.WidthPixels); int id = 0; /* SpannableStringBuilder prettyMessage = new SpannableStringBuilder(Message); * int italicsFrom = Message.IndexOf(ItalicsString), italicsTo = italicsFrom + ItalicsString.Length; * prettyMessage.SetSpan(new StyleSpan(TypefaceStyle.Italic), italicsFrom, italicsTo, SpanTypes.ExclusiveExclusive); */ layout = new LinearLayout(this); layout.Orientation = Orientation.Vertical; layout.SetBackgroundColor(Color.White); ScrollView sv = new ScrollView(this); LayoutParams scrollParams = new LayoutParams(LayoutParams.MatchParent, 0); scrollParams.Weight = 1; //this.layout.addView(sv, scrollParams); LinearLayout innerLayout = new LinearLayout(this); innerLayout.Orientation = Orientation.Vertical; LayoutParams ilParams = new LayoutParams(LayoutParams.MatchParent, 0); ilParams.Weight = 1; sv.AddView(innerLayout, ilParams); messageText = new TextView(this); messageText.Text = Message; //messageText.SetText(prettyMessage, TextView.BufferType.Spannable); messageText.TextSize = 14; messageText.Gravity = GravityFlags.Left | GravityFlags.CenterVertical; LayoutParams textParams = new LayoutParams(LayoutParams.MatchParent, LayoutParams.WrapContent); textParams.Weight = 0; textParams.Gravity = GravityFlags.Left | GravityFlags.CenterVertical; textParams.SetMargins(margin, margin, margin, margin / 2); layout.AddView(messageText, textParams); EditText detail = new EditText(this); detail.Id = id++; detail.Hint = "Wat wil je zeggen?"; detail.InputType = InputTypes.ClassText | InputTypes.TextFlagMultiLine; detail.Gravity = GravityFlags.Top; LayoutParams detailParams = new LayoutParams(LayoutParams.MatchParent, 0); detailParams.Weight = 0.5f; detailParams.SetMargins(margin, 0, margin, 0); layout.AddView(detail, detailParams); EditText sender = new EditText(this); sender.Id = id++; sender.InputType = InputTypes.ClassText; sender.Hint = "Hoe kan ik je bereiken?"; LayoutParams senderParams = new LayoutParams(LayoutParams.MatchParent, LayoutParams.WrapContent); senderParams.Weight = 0; senderParams.SetMargins(margin, 0, margin, 0); layout.AddView(sender, senderParams); loading = new ProgressBar(this) { Indeterminate = true }; submit = new Button(this); submit.Text = "Versturen"; submitParams = new LayoutParams(LayoutParams.WrapContent, LayoutParams.WrapContent); submitParams.Weight = 0; submitParams.SetMargins(0, 0, 0, margin); submitParams.Gravity = GravityFlags.Center; submit.Click += (s, e) => { Utils.HideOnScreenKeyboard(sender.WindowToken); Utils.HideOnScreenKeyboard(detail.WindowToken); layout.RemoveView(submit); layout.AddView(loading, submitParams); Task.Factory.StartNew(() => SendFeedback(sender.Text, detail.Text)).ContinueHere( completeTask => { Toast.MakeText(Utils.Context, "Je feedback is verzonden!", ToastLength.Short).Show(); Finish(); }, faultedTask => { Console.WriteLine(faultedTask.Exception.InnerException); messageText.SetHeight(messageText.Height); messageText.Gravity = GravityFlags.Center; messageText.Text = "Er ging iets mis met het versturen van je feedback.\n" + "Misschien moet je het later nog eens proberen?"; layout.RemoveView(loading); layout.AddView(submit, submitParams); isLoading = false; }); isLoading = true; }; if (isLoading) { layout.AddView(loading, submitParams); } else { layout.AddView(submit, submitParams); } SetContentView(layout); }
public void list() { linearLayout1.RemoveAllViews(); try { using (var client = new WebClient()) { string id = Library.ControlID.userID; var json = client.DownloadString("http://joremtongwebsite.000webhostapp.com/sectionList.php?profuserID=" + id); dynamic jsonData = JsonConvert.DeserializeObject(json); foreach (dynamic jsonDatas in jsonData) { var layout2 = new LinearLayout(this); layout2.Orientation = Orientation.Horizontal; var layoutParams2 = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.WrapContent); layoutParams2.SetMargins(0, 0, 0, 20); layout2.SetBackgroundResource(Resource.Drawable.layout_bg); layout2.SetPadding(0, 0, 0, 0); layout2.LayoutParameters = layoutParams2; var Image = new ImageView(this); var param = new LayoutParams(150, 150); Image.LayoutParameters = param; Image.SetPadding(30, 50, 0, 0); Image.SetImageResource(Resource.Drawable.exclamation); var layout = new LinearLayout(this); layout.Orientation = Orientation.Vertical; var layoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.WrapContent); layoutParams.SetMargins(0, 0, 0, 20); layout.SetBackgroundResource(Resource.Drawable.layout_bg); layout.SetPadding(0, 0, 0, 0); layout.LayoutParameters = layoutParams; layout.Click += async delegate { UserDialogs.Instance.ShowLoading("Loading", MaskType.Black); await Task.Delay(1000); Intent activity = new Intent(this, typeof(AddHandOutsActivity)); activity.PutExtra("ID", jsonDatas["sectionID"].ToString()); StartActivity(activity); UserDialogs.Instance.HideLoading(); }; var username = new TextView(this); username.SetTextColor(Color.White); username.SetTypeface(Typeface.Default, TypefaceStyle.BoldItalic); username.SetTextSize(global::Android.Util.ComplexUnitType.Dip, 20); username.Text = jsonDatas["subject"].ToString(); username.SetPadding(20, 20, 20, 0); var Title = new TextView(this); Title.SetTextColor(Color.White); Title.SetTypeface(Typeface.Default, TypefaceStyle.BoldItalic); Title.SetTextSize(global::Android.Util.ComplexUnitType.Dip, 15); Title.Text = jsonDatas["course"].ToString(); Title.SetPadding(20, 0, 20, 8); var content = new TextView(this); content.SetTextColor(Color.DimGray); content.SetTextSize(global::Android.Util.ComplexUnitType.Dip, 15); content.Text = jsonDatas["section"].ToString(); content.SetPadding(20, 0, 20, 0); layout.AddView(username); layout.AddView(Title); layout.AddView(content); layout2.AddView(Image); layout2.AddView(layout); linearLayout1.AddView(layout2); } } } catch (Exception i) { var layout = new LinearLayout(this); layout.Orientation = Orientation.Vertical; LayoutParams layoutParams = new LayoutParams(LinearLayout.LayoutParams.MatchParent, LinearLayout.LayoutParams.WrapContent); layoutParams.SetMargins(5, 5, 5, 5); layout.SetBackgroundColor(Color.White); layout.SetPadding(0, 0, 0, 0); var username = new TextView(this); username.SetTextColor(Color.Red); username.SetTypeface(Typeface.Default, TypefaceStyle.BoldItalic); username.SetTextSize(global::Android.Util.ComplexUnitType.Dip, 20); username.Text = "NO DATA YET"; username.SetPadding(20, 20, 20, 0); layout.AddView(username); linearLayout1.AddView(layout); } }
private void InitLayout(IAttributeSet attrs, Context context) { if (attrs == null) { throw new Exception("You need to set attribut with this component <SectionBarLayout>"); } if (context == null) { throw new Exception("You need to set context for <SectionBarLayout>"); } _context = context; // placeholder de l'EditText var titleAttributArray = _context.ObtainStyledAttributes(attrs, Resource.Styleable.ImageEditTextLayout); var titleValue = titleAttributArray.GetString(Resource.Styleable.ImageEditTextLayout_textPlaceholder); // image de l'EditText var imageAttributArray = _context.ObtainStyledAttributes(attrs, Resource.Styleable.ImageEditTextLayout); var imageValue = imageAttributArray.GetResourceId(Resource.Styleable.ImageEditTextLayout_imageEditText, 0); // size du text de l'edit text var sizeTextAttributeArray = _context.ObtainStyledAttributes(attrs, Resource.Styleable.ImageEditTextLayout); var sizeTextValue = sizeTextAttributeArray.GetResourceId(Resource.Styleable.ImageEditTextLayout_imageEditTextSize, 0); // layout de l'image var imageLayout = new RelativeLayout(_context); imageLayout.LayoutParameters = new RelativeLayout.LayoutParams(AccessResources.Instance.SizeOf60Dip(), AccessResources.Instance.SizeOf60Dip()); imageLayout.SetBackgroundColor(AccessResources.Instance.ColorLayoutBackgroundSecondary()); imageLayout.Clickable = true; // initialisation de l'EditText EditText = new EditText(Context); EditText.SetTextColor(AccessResources.Instance.ColorTextColorContent()); EditText.SetHintTextColor(AccessResources.Instance.ColorTextColorHint()); EditText.SetTextSize(ComplexUnitType.Dip, 16); EditText.Hint = titleValue; EditText.SetPadding(0, 2, 0, 0); EditText.InputType = Android.Text.InputTypes.TextVariationUri; EditText.SetBackgroundResource(Resource.Drawable.EditTextParameterTemplate); EditText.Focusable = true; var titleTextParam = new LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.WrapContent); titleTextParam.AddRule(LayoutRules.CenterVertical); titleTextParam.SetMargins(AccessResources.Instance.SizeOf70Dip(), 0, 0, 0); EditText.LayoutParameters = titleTextParam; // image SVG var imageButtonSvgImage = new XamSvg.SvgImageView(_context, attrs); imageButtonSvgImage.SetSvg(_context, imageValue, string.Empty, string.Empty); var imageButtonParam = new LayoutParams(AccessResources.Instance.SizeOf30Dip(), AccessResources.Instance.SizeOf30Dip()); imageButtonParam.AddRule(LayoutRules.CenterInParent); imageButtonSvgImage.LayoutParameters = imageButtonParam; imageLayout.Click += ((o, e) => { EditText.SetSelection(EditText.Text.Length); EditText.RequestFocus(); InputMethodManager imm = (InputMethodManager)_context.GetSystemService(Context.InputMethodService); imm.ShowSoftInput(EditText, InputMethodManager.ShowImplicit); }); // ajout du titre dans la vue AddView(EditText); imageLayout.AddView(imageButtonSvgImage); AddView(imageLayout); }
public void listOfStudent() { linearLayout1.RemoveAllViews(); try { using (var client = new WebClient()) { string userID = Library.ControlID.userID; string id = Library.ControlID.userID; var json = client.DownloadString("http://joremtongwebsite.000webhostapp.com/titleQuizList.php?userID=" + userID); dynamic jsonData = JsonConvert.DeserializeObject(json); foreach (dynamic jsonDatas in jsonData) { var layout2 = new LinearLayout(this); layout2.Orientation = Orientation.Horizontal; var layoutParams2 = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.WrapContent); layoutParams2.SetMargins(0, 0, 0, 20); layout2.SetBackgroundResource(Resource.Drawable.layout_bg); layout2.SetPadding(0, 0, 0, 0); layout2.LayoutParameters = layoutParams2; var Image = new ImageView(this); var param = new LayoutParams(150, 150); Image.LayoutParameters = param; Image.SetPadding(30, 10, 0, 0); Image.SetImageResource(Resource.Drawable.answer); var layout = new LinearLayout(this); layout.Orientation = Orientation.Vertical; var layoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.WrapContent); layoutParams.SetMargins(0, 0, 0, 20); layout.SetBackgroundResource(Resource.Drawable.layout_bg); layout.SetPadding(0, 0, 0, 0); layout.LayoutParameters = layoutParams; layout.Click += delegate { Library.ControlID.quizTitleID = jsonDatas["quizID"].ToString(); Intent activity = new Intent(this, typeof(QuizFreeViewActivity)); StartActivity(activity); }; var username = new TextView(this); username.SetTextColor(Color.White); username.SetTypeface(Typeface.Default, TypefaceStyle.Bold); username.SetTextSize(global::Android.Util.ComplexUnitType.Dip, 20); username.Text = jsonDatas["title"].ToString(); username.SetPadding(20, 20, 20, 0); layout.AddView(username); layout2.AddView(Image); layout2.AddView(layout); linearLayout1.AddView(layout2); } } } catch (Exception i) { var layout = new LinearLayout(this); layout.Orientation = Orientation.Vertical; LayoutParams layoutParams = new LayoutParams(LinearLayout.LayoutParams.MatchParent, LinearLayout.LayoutParams.WrapContent); layoutParams.SetMargins(5, 5, 5, 5); layout.SetBackgroundColor(Color.White); layout.SetPadding(0, 0, 0, 0); var username = new TextView(this); username.SetTextColor(Color.Red); username.SetTypeface(Typeface.Default, TypefaceStyle.BoldItalic); username.SetTextSize(global::Android.Util.ComplexUnitType.Dip, 20); username.Text = "NO DATA YET"; username.SetPadding(20, 20, 20, 0); layout.AddView(username); linearLayout1.AddView(layout); } }
/// <summary> /// Ajoute un contact à l'élément parent (LinearLayout) /// </summary> /// <param name="contact">contact à ajouter</param> public void AddChild(Contact contact) { if (contact == null) { return; } var emptyTextView = FindViewById(12); if (emptyTextView != null) { RemoveView(emptyTextView); } // layout for displaying the name and the phone number or email var numberEmailLayout = new LinearLayout(Context); var layoutParammainLayout = new LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.MatchParent); numberEmailLayout.Clickable = true; numberEmailLayout.Orientation = Orientation.Vertical; numberEmailLayout.SetBackgroundColor(Color.Transparent); numberEmailLayout.LayoutParameters = layoutParammainLayout; // layout that contains all the element var rootLayout = new LinearLayout(Context); var layoutParamLayout = new LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.MatchParent); rootLayout.Clickable = true; rootLayout.Orientation = Orientation.Horizontal; rootLayout.SetBackgroundColor(Color.Transparent); rootLayout.SetPadding(AccessResources.Instance.SizeOf5Dip() , AccessResources.Instance.SizeOf5Dip() , AccessResources.Instance.SizeOf5Dip() , AccessResources.Instance.SizeOf5Dip()); rootLayout.LayoutParameters = layoutParamLayout; // display the name var contactTextView = new TextView(Context); contactTextView.Id = 13; var layoutParamTextView = new LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent); layoutParamTextView.Gravity = GravityFlags.CenterVertical; contactTextView.Text = contact.DisplayName; contactTextView.SetTextColor(Color.ParseColor(Resources.GetString(Resource.Color.textColorContent))); contactTextView.SetTextSize(ComplexUnitType.Dip, 16); contactTextView.LayoutParameters = layoutParamTextView; contactTextView.Clickable = false; // delete button var buttonDeleteContact = new SvgImageView(Context); var layoutParamButton = new LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent); layoutParamButton.Gravity = GravityFlags.Top; layoutParamButton.Height = AccessResources.Instance.SizeOf20Dip(); layoutParamButton.Width = AccessResources.Instance.SizeOf20Dip(); layoutParamButton.SetMargins(AccessResources.Instance.SizeOf10Dip(), AccessResources.Instance.SizeOf5Dip(), AccessResources.Instance.SizeOf10Dip(), 0); buttonDeleteContact.SetSvg(Context, Resource.Drawable.RoundedDelete); buttonDeleteContact.LayoutParameters = layoutParamButton; buttonDeleteContact.Click += ((o, e) => { App.Locator.Alert.LsRecipients.RemoveAll(el => el.DisplayName.TrimEnd(' ') == contact.DisplayName); App.Locator.AlertSOS.LsRecipients.RemoveAll(el => el.DisplayName.TrimEnd(' ') == contact.DisplayName); RemoveView(rootLayout); ContactInit(); }); // display the phone number or the email var phoneEmailTextView = new TextView(Context); var layoutParamTxtView = new LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent); layoutParamTxtView.Gravity = GravityFlags.CenterVertical; phoneEmailTextView.SetPadding(0, AccessResources.Instance.SizeOf5Dip(), 0, 0); phoneEmailTextView.Text = contact.Email; phoneEmailTextView.SetTextColor(Color.ParseColor(Resources.GetString(Resource.Color.textColorContent))); phoneEmailTextView.SetTextSize(ComplexUnitType.Dip, 14); phoneEmailTextView.LayoutParameters = layoutParamTxtView; phoneEmailTextView.Clickable = false; numberEmailLayout.AddView(contactTextView); numberEmailLayout.AddView(phoneEmailTextView); rootLayout.AddView(numberEmailLayout); rootLayout.AddView(buttonDeleteContact); AddView(rootLayout); }
public void list() { try { linearLayout1.RemoveAllViews(); using (var client = new WebClient()) { var json = client.DownloadString("http://joremtongwebsite.000webhostapp.com/quizall.php?quizID=" + quizID); dynamic jsonData = JsonConvert.DeserializeObject(json); foreach (dynamic jsonDatas in jsonData) { var choiceanswer = new TextView(this); choiceanswer.SetTextColor(Color.Black); choiceanswer.Text = "Sample"; choiceanswer.SetTypeface(Typeface.Default, TypefaceStyle.BoldItalic); choiceanswer.SetTextSize(global::Android.Util.ComplexUnitType.Dip, 0); choiceanswer.SetPadding(20, 0, 20, 8); var qanswer = new TextView(this); qanswer.SetTextColor(Color.White); qanswer.SetTypeface(Typeface.Default, TypefaceStyle.BoldItalic); qanswer.SetTextSize(global::Android.Util.ComplexUnitType.Dip, 0); qanswer.Text = jsonDatas["correctanswer"].ToString(); qanswer.SetPadding(20, 0, 20, 8); var layout = new LinearLayout(this); layout.Orientation = Orientation.Vertical; var layoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.WrapContent); layoutParams.SetMargins(0, 0, 0, 20); layout.SetBackgroundResource(Resource.Drawable.layout_bg); layout.SetPadding(0, 0, 0, 0); layout.LayoutParameters = layoutParams; var question = new TextView(this); question.SetTextColor(Color.White); question.SetTypeface(Typeface.Default, TypefaceStyle.Bold); question.SetTextSize(global::Android.Util.ComplexUnitType.Dip, 20); question.Text = jsonDatas["question"].ToString(); question.SetPadding(20, 0, 20, 8); var group = new RadioGroup(this); group.Orientation = Orientation.Vertical; LayoutParams rgroup = new LayoutParams(RadioGroup.LayoutParams.MatchParent, RadioGroup.LayoutParams.WrapContent); rgroup.SetMargins(5, 5, 5, 5); group.SetBackgroundColor(Color.Rgb(37, 36, 36)); var choice1 = new RadioButton(this); choice1.SetTextColor(Color.White); choice1.SetTextSize(global::Android.Util.ComplexUnitType.Dip, 15); choice1.Text = jsonDatas["choiceone"].ToString(); choice1.Click += delegate { choiceanswer.Text = ""; choiceanswer.Text = choice1.Text; if (choiceanswer.Text == qanswer.Text) { total++; } }; choice1.SetPadding(20, 0, 20, 0); var choice2 = new RadioButton(this); choice2.SetTextColor(Color.White); choice2.SetTextSize(global::Android.Util.ComplexUnitType.Dip, 15); choice2.Text = jsonDatas["choicetwo"].ToString(); choice2.Click += delegate { choiceanswer.Text = ""; choiceanswer.Text = choice2.Text; if (choiceanswer.Text == qanswer.Text) { total++; } }; choice2.SetPadding(20, 0, 20, 0); var choice3 = new RadioButton(this); choice3.SetTextColor(Color.White); choice3.SetTextSize(global::Android.Util.ComplexUnitType.Dip, 15); choice3.Text = jsonDatas["choicethree"].ToString(); choice3.Click += delegate { choiceanswer.Text = ""; choiceanswer.Text = choice3.Text; if (choiceanswer.Text == qanswer.Text) { total++; } }; choice3.SetPadding(20, 0, 20, 0); var choice4 = new RadioButton(this); choice4.SetTextColor(Color.White); choice4.SetTextSize(global::Android.Util.ComplexUnitType.Dip, 15); choice4.Text = jsonDatas["choicefour"].ToString(); choice4.Click += delegate { choiceanswer.Text = ""; choiceanswer.Text = choice4.Text; if (choiceanswer.Text == qanswer.Text) { total++; } }; choice4.SetPadding(20, 0, 20, 0); layout.AddView(question); group.AddView(choice1); group.AddView(choice2); group.AddView(choice3); group.AddView(choice4); layout.AddView(group); layout.AddView(qanswer); layout.AddView(choiceanswer); linearLayout1.AddView(layout); } } } catch (Exception i) { Toast.MakeText(this, i.Message, ToastLength.Long).Show(); } }
public void listOfStudent() { linearLayout1.RemoveAllViews(); try { using (var client = new WebClient()) { DateTime date = DateTime.Now; string id = Library.ControlID.userID; var json = client.DownloadString("http://joremtongwebsite.000webhostapp.com/attendanceList.php?DATE=" + date.ToString("yyyy-MM-dd") + "&§ionID=" + ID); dynamic jsonData = JsonConvert.DeserializeObject(json); foreach (dynamic jsonDatas in jsonData) { var layout2 = new LinearLayout(this); layout2.Orientation = Orientation.Horizontal; var layoutParams2 = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.WrapContent); layoutParams2.SetMargins(0, 0, 0, 20); layout2.SetBackgroundResource(Resource.Drawable.layout_bg); layout2.SetPadding(0, 0, 0, 0); layout2.LayoutParameters = layoutParams2; var Image = new ImageView(this); var param = new LayoutParams(120, 120); Image.LayoutParameters = param; Image.SetPadding(20, 30, 0, 0); Image.SetImageResource(Resource.Drawable.study); var layout = new LinearLayout(this); layout.Orientation = Orientation.Vertical; var layoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.WrapContent);; layoutParams.SetMargins(0, 0, 0, 20); layout.SetBackgroundResource(Resource.Drawable.layout_bg); layout.SetPadding(10, 10, 10, 50); layout.LayoutParameters = layoutParams; var username = new TextView(this); username.SetTextColor(Color.White); username.SetTypeface(Typeface.Default, TypefaceStyle.BoldItalic); username.SetTextSize(global::Android.Util.ComplexUnitType.Dip, 20); username.Text = jsonDatas["fullName"].ToString(); username.SetPadding(20, 20, 20, 0); layout.AddView(username); layout2.AddView(Image); layout2.AddView(layout); linearLayout1.AddView(layout2); } } } catch (Exception i) { var layout = new LinearLayout(this); layout.Orientation = Orientation.Vertical; LayoutParams layoutParams = new LayoutParams(LinearLayout.LayoutParams.MatchParent, LinearLayout.LayoutParams.WrapContent); layoutParams.SetMargins(5, 5, 5, 5); layout.SetBackgroundColor(Color.White); layout.SetPadding(0, 0, 0, 0); var username = new TextView(this); username.SetTextColor(Color.Red); username.SetTypeface(Typeface.Default, TypefaceStyle.BoldItalic); username.SetTextSize(global::Android.Util.ComplexUnitType.Dip, 20); username.Text = "NO DATA YET"; username.SetPadding(20, 20, 20, 0); layout.AddView(username); linearLayout1.AddView(layout); } }
protected override void OnFinishInflate() { base.OnFinishInflate(); //add @layout/material_view_pager_layout as child, containing all the MaterialViewPager views AddView(LayoutInflater.From(Context).Inflate(Resource.Layout.material_view_pager_layout, this, false)); _headerBackgroundContainer = FindViewById <ViewGroup>(Resource.Id.headerBackgroundContainer); _pagerTitleStripContainer = FindViewById <ViewGroup>(Resource.Id.pagerTitleStripContainer); _logoContainer = FindViewById <ViewGroup>(Resource.Id.logoContainer); MToolbar = FindViewById <Toolbar>(Resource.Id.toolbar); if (Settings.DisableToolbar) { MToolbar.Visibility = ViewStates.Invisible; } MViewPager = FindViewById <ViewPager>(Resource.Id.viewPager); MViewPager.AddOnPageChangeListener(this); //inflate subviews defined in attributes { int headerId = Settings.HeaderLayoutId; if (headerId == -1) { headerId = Settings.AnimatedHeaderImage ? Resource.Layout.material_view_pager_moving_header : Resource.Layout.material_view_pager_imageview_header; } _headerBackgroundContainer.AddView(LayoutInflater.From(Context).Inflate(headerId, _headerBackgroundContainer, false)); } if (IsInEditMode) { //preview titlestrip //add fake tabs on edit mode Settings.PagerTitleStripId = Resource.Layout.tools_material_view_pager_pagertitlestrip; } if (Settings.PagerTitleStripId != -1) { _pagerTitleStripContainer.AddView(LayoutInflater.From(Context).Inflate(Settings.PagerTitleStripId, _pagerTitleStripContainer, false)); } if (Settings.LogoLayoutId != -1) { _logoContainer.AddView(LayoutInflater.From(Context).Inflate(Settings.LogoLayoutId, _logoContainer, false)); if (Settings.LogoMarginTop != 0) { RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams)_logoContainer.LayoutParameters; layoutParams.SetMargins(0, Settings.LogoMarginTop, 0, 0); _logoContainer.LayoutParameters = layoutParams; } } HeaderBackground = FindViewById(Resource.Id.headerBackground); ToolbarLayoutBackground = FindViewById(Resource.Id.toolbar_layout_background); InitialiseHeights(); //construct the materialViewPagerHeader with subviews if (!IsInEditMode) { MaterialViewPagerHeader = MaterialViewPagerHeader .WithToolbar(MToolbar) .WithToolbarLayoutBackground(ToolbarLayoutBackground) .WithPagerSlidingTabStrip(_pagerTitleStripContainer) .WithHeaderBackground(HeaderBackground) .WithStatusBackground(FindViewById(Resource.Id.statusBackground)) .WithLogo(_logoContainer); //and construct the MaterialViewPagerAnimator //attach it to the activity to enable MaterialViewPagerHeaderView.setMaterialHeight(); MaterialViewPagerHelper.Register(Context, new MaterialViewPagerAnimator(this)); } else { //if in edit mode, add fake cardsviews View sample = LayoutInflater.From(Context).Inflate(Resource.Layout.tools_list_items, _pagerTitleStripContainer, false); LayoutParams param = (LayoutParams)sample.LayoutParameters; int marginTop = (int)Math.Round(Utils.DpToPx(Settings.HeaderHeight + 10, Context)); param.SetMargins(0, marginTop, 0, 0); LayoutParameters = param; AddView(sample); } }
/** * Programmatically build up the view hierarchy to avoid the need for resources. * @return View hierarchy */ private View generateHierarchy(Context context) { Resources resources = this.Resources; FrameLayout.LayoutParams _params; int fivePx = Util.dpToPx(5, resources); int tenPx = Util.dpToPx(10, resources); int twentyPx = Util.dpToPx(20, resources); TableLayout.LayoutParams tableLayoutParams = new TableLayout.LayoutParams( 0, ViewGroup.LayoutParams.WrapContent, 1f); tableLayoutParams.SetMargins(0, 0, fivePx, 0); LinearLayout seekWrapper; FrameLayout root = new FrameLayout(context); _params = new LayoutParams(ViewGroup.LayoutParams.MatchParent, Util.dpToPx(300, resources)); root.LayoutParameters = _params; FrameLayout container = new FrameLayout(context); _params = new LayoutParams(LayoutParams.MatchParent, LayoutParams.MatchParent); _params.SetMargins(0, twentyPx, 0, 0); container.LayoutParameters = _params; container.SetBackgroundColor(Color.Argb(100, 0, 0, 0)); root.AddView(container); mSpringSelectorSpinner = new Spinner(context, SpinnerMode.Dialog); _params = new LayoutParams(LayoutParams.MatchParent, LayoutParams.WrapContent); _params.Gravity = GravityFlags.Top; _params.SetMargins(tenPx, tenPx, tenPx, 0); mSpringSelectorSpinner.LayoutParameters = _params; container.AddView(mSpringSelectorSpinner); LinearLayout linearLayout = new LinearLayout(context); _params = new LayoutParams(LayoutParams.MatchParent, LayoutParams.WrapContent); _params.SetMargins(0, 0, 0, Util.dpToPx(80, resources)); _params.Gravity = GravityFlags.Bottom; linearLayout.LayoutParameters = _params; linearLayout.Orientation = Android.Widget.Orientation.Vertical; container.AddView(linearLayout); seekWrapper = new LinearLayout(context); _params = new LayoutParams(LayoutParams.MatchParent, LayoutParams.WrapContent); _params.SetMargins(tenPx, tenPx, tenPx, twentyPx); seekWrapper.SetPadding(tenPx, tenPx, tenPx, tenPx); seekWrapper.LayoutParameters = _params; seekWrapper.Orientation = Android.Widget.Orientation.Horizontal; linearLayout.AddView(seekWrapper); mTensionSeekBar = new SeekBar(context); mTensionSeekBar.LayoutParameters = tableLayoutParams; seekWrapper.AddView(mTensionSeekBar); mTensionLabel = new TextView(Context); mTensionLabel.SetTextColor(mTextColor); _params = new LayoutParams( Util.dpToPx(50, resources), ViewGroup.LayoutParams.MatchParent); mTensionLabel.Gravity = GravityFlags.CenterVertical | GravityFlags.Left; mTensionLabel.LayoutParameters = _params; mTensionLabel.SetMaxLines(1); seekWrapper.AddView(mTensionLabel); seekWrapper = new LinearLayout(context); _params = new LayoutParams(LayoutParams.MatchParent, LayoutParams.WrapContent); _params.SetMargins(tenPx, tenPx, tenPx, twentyPx); seekWrapper.SetPadding(tenPx, tenPx, tenPx, tenPx); seekWrapper.LayoutParameters = _params; seekWrapper.Orientation = Android.Widget.Orientation.Horizontal; linearLayout.AddView(seekWrapper); mFrictionSeekBar = new SeekBar(context); mFrictionSeekBar.LayoutParameters = tableLayoutParams; seekWrapper.AddView(mFrictionSeekBar); mFrictionLabel = new TextView(Context); mFrictionLabel.SetTextColor(mTextColor); _params = new LayoutParams(Util.dpToPx(50, resources), ViewGroup.LayoutParams.MatchParent); mFrictionLabel.Gravity = GravityFlags.CenterVertical | GravityFlags.Left; mFrictionLabel.LayoutParameters = _params; mFrictionLabel.SetMaxLines(1); seekWrapper.AddView(mFrictionLabel); View nub = new View(context); _params = new LayoutParams(Util.dpToPx(60, resources), Util.dpToPx(40, resources)); _params.Gravity = GravityFlags.Top | GravityFlags.Center; nub.LayoutParameters = _params; nub.SetOnTouchListener(new OnNubTouchListener() { Touch = (View, motionEvent) => { if (motionEvent.Action == MotionEventActions.Down) { togglePosition(); } return(true); } }); nub.SetBackgroundColor(Color.Argb(255, 0, 164, 209)); root.AddView(nub); return(root); }