public override View GetPropertyWindowLayout (Android.Content.Context context) { gridlayout = new GridLayout (context); gridlayout.RowCount = 2; gridlayout.ColumnCount = 2; conditionTextView = new TextView (context); conditionTextView.Text = "Select the Condition to filter"; columnTextView = new TextView (context); columnTextView.Text = "Select the Column to filter"; columnDropdown = new Spinner(context); var columnAdapter = ArrayAdapter.CreateFromResource (context, Resource.Array.column_array, Android.Resource.Layout.SimpleSpinnerItem); columnAdapter.SetDropDownViewResource (Android.Resource.Layout.SimpleSpinnerDropDownItem); columnDropdown.Adapter = columnAdapter; conditionDropdown = new Spinner (context); condtionAdapter = new ArrayAdapter (context, Android.Resource.Layout.SimpleSpinnerItem); condtionAdapter.SetDropDownViewResource (Android.Resource.Layout.SimpleSpinnerDropDownItem); conditionDropdown.Adapter = condtionAdapter; columnDropdown.ItemSelected += new EventHandler<AdapterView.ItemSelectedEventArgs> (OnColumnSelected); conditionDropdown.ItemSelected += OnConditionSelected; gridlayout.LayoutParameters = new LinearLayout.LayoutParams (LinearLayout.LayoutParams.MatchParent, LinearLayout.LayoutParams.WrapContent); gridlayout.AddView (columnTextView); gridlayout.AddView (columnDropdown); gridlayout.AddView (conditionTextView); gridlayout.AddView (conditionDropdown); return gridlayout; }
private void PopulateGridLayoutWithTroopProgress(GridLayout grid, Context ctx) { using (var db = new SQLite.SQLiteConnection(AppState.State.Instance.DbPath)) { var users = db.Table <User>().ToList(); var groupedChallengeProgress = db.Table <ChallengeProgress>().ToList().GroupBy(c => c.UserId); foreach (var user in users) { var memberProgresses = groupedChallengeProgress.Single((g) => g.Key == user.Id).ToList(); var memberName = new TextView(ctx) { Text = user.Name, }; var activeChallenges = new TextView(ctx) { Text = memberProgresses.Count((p) => p.Status >= Models.ProgressStatus.Completed).ToString(), }; activeChallenges.SetPadding(20, 0, 20, 0); var finishedChallenges = new TextView(ctx) { Text = memberProgresses.Count((p) => p.Status == Models.ProgressStatus.InProgress).ToString(), }; finishedChallenges.SetPadding(20, 0, 20, 0); grid.AddView(memberName); grid.AddView(activeChallenges); grid.AddView(finishedChallenges); } } }
public GettingStartedTemplate(Context context) : base(context) { this.ColumnCount = 2; this.RowCount = 1; var paddingValue = (int)(15 * Resources.DisplayMetrics.Density); this.SetPadding(paddingValue, paddingValue, paddingValue / 2, paddingValue); imageView = new ImageView(context); imageView.SetMaxHeight((int)(100 * this.Resources.DisplayMetrics.Density)); imageView.SetMaxWidth((int)(80 * this.Resources.DisplayMetrics.Density)); label1 = new TextView(context); label2 = new TextView(context); label3 = new TextView(context); label4 = new TextView(context); detailsLayout = new GridLayout(context); detailsLayout.RowCount = 4; detailsLayout.ColumnCount = 1; detailsLayout.AddView(label1); detailsLayout.AddView(label2); detailsLayout.AddView(label3); detailsLayout.AddView(label4); this.AddView(imageView, (int)(80 * this.Resources.DisplayMetrics.Density), (int)(100 * this.Resources.DisplayMetrics.Density)); this.AddView(detailsLayout, ViewGroup.LayoutParams.MatchParent, (int)(100 * this.Resources.DisplayMetrics.Density)); }
public ConctactTemplate(Context context) : base(context) { this.SetPadding(25, 25, 25, 25); this.ColumnCount = 2; this.RowCount = 1; label1 = new CircleView(context); label1.SetTypeface(Typeface.DefaultBold, TypefaceStyle.Bold); label1.TextSize = 25; label1.Gravity = GravityFlags.Center; label1.SetTextColor(Color.White); label2 = new TextView(context); label3 = new TextView(context); label2.Gravity = GravityFlags.Start; label3.Gravity = GravityFlags.Start; label2.SetTextColor(Color.Black); label2.TextSize = 18; label3.TextSize = 14; label3.SetTextColor(Color.LightGray); detailsLayout = new GridLayout(context); detailsLayout.RowCount = 4; detailsLayout.ColumnCount = 1; detailsLayout.AddView(label2); detailsLayout.AddView(label3); detailsLayout.SetPadding((int)(20 * this.Resources.DisplayMetrics.Density), (int)(5 * this.Resources.DisplayMetrics.Density), 0, 0); this.AddView(label1, (int)(50 * this.Resources.DisplayMetrics.Density), (int)(50 * this.Resources.DisplayMetrics.Density)); this.AddView(detailsLayout); }
void PutZeroHour() { GridLayout glZero = new GridLayout(this) { ColumnCount = 3, RowCount = 1 }; glZero.SetBackgroundColor(Color.White); glZero.AddView(new TextView(this) { Text = "0" }); View line = new View(this); line.SetBackgroundColor(Color.Rgb(149, 152, 154)); line.SetMinimumWidth(1); line.SetMinimumHeight(60); if ((int)Build.VERSION.SdkInt > 22) { line.SetForegroundGravity(GravityFlags.Right); } glZero.AddView(line); llhHorario.AddView(glZero); }
public override View GetPropertyWindowLayout(Android.Content.Context context) { gridlayout = new GridLayout(context); gridlayout.RowCount = 2; gridlayout.ColumnCount = 2; conditionTextView = new TextView(context); conditionTextView.Text = "Select the Condition to filter"; columnTextView = new TextView(context); columnTextView.Text = "Select the Column to filter"; columnDropdown = new Spinner(context, SpinnerMode.Dialog); var columnAdapter = ArrayAdapter.CreateFromResource(context, Resource.Array.column_array, Android.Resource.Layout.SimpleSpinnerItem); columnAdapter.SetDropDownViewResource(Android.Resource.Layout.SimpleSpinnerDropDownItem); columnDropdown.Adapter = columnAdapter; conditionDropdown = new Spinner(context, SpinnerMode.Dialog); condtionAdapter = new ArrayAdapter(context, Android.Resource.Layout.SimpleSpinnerItem); condtionAdapter.SetDropDownViewResource(Android.Resource.Layout.SimpleSpinnerDropDownItem); conditionDropdown.Adapter = condtionAdapter; columnDropdown.ItemSelected += new EventHandler <AdapterView.ItemSelectedEventArgs> (OnColumnSelected); conditionDropdown.ItemSelected += OnConditionSelected; gridlayout.LayoutParameters = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MatchParent, LinearLayout.LayoutParams.WrapContent); gridlayout.AddView(columnTextView); gridlayout.AddView(columnDropdown); gridlayout.AddView(conditionTextView); gridlayout.AddView(conditionDropdown); return(gridlayout); }
private void tileMakerMethod() { // know the grid size ... gridSize // know the tile width and height //know where to place tile in grid layout //know which image to display on tiles tileWidth = screenWidth / gridSize; System.String imageName; int imgNumber = 0; for (int h = 0; h < gridSize; h++) { for (int v = 0; v < gridSize; v++) { ImageView imgTile = new ImageView(this); Point thisCoord = new Point(h, v); coordsArr.Add(thisCoord); GridLayout.Spec rowSpec = GridLayout.InvokeSpec(thisCoord.X); GridLayout.Spec colSpec = GridLayout.InvokeSpec(thisCoord.Y); GridLayout.LayoutParams tileParams = new GridLayout.LayoutParams(rowSpec, colSpec); tileParams.Width = tileWidth; tileParams.Height = tileWidth; if (imgNumber == gridSize * gridSize / 2) { imgNumber = 0; } imageName = imgsArr[imgNumber] as string; int resId = Resources.GetIdentifier(imageName, "drawable", PackageName); imgTile.SetImageResource(resId); imgTile.LayoutParameters = tileParams; imgTile.SetOnTouchListener(this); tilesArr.Add(imgTile); gameGridLayout.AddView(imgTile); imgNumber++; } } // have an array of all tiles //ORDERED from 0 to gridsize X gridSize // and have an array of all coords. }
private void tileMakerMethod( ) { tileWidth = screenWidth / gridSize; System.String imageName; int imgNumber = 0; for (int h = 0; h < gridSize; h++) { for (int v = 0; v < gridSize; v++) { ImageView imgTile = new ImageView(this); Point thisCoord = new Point(h, v); coordsArr.Add(thisCoord); GridLayout.Spec rowSpec = GridLayout.InvokeSpec(h); GridLayout.Spec colSpec = GridLayout.InvokeSpec(v); GridLayout.LayoutParams tileParams = new GridLayout.LayoutParams(rowSpec, colSpec); tileParams.Width = tileWidth; tileParams.Height = tileWidth; if (imgNumber == gridSize * gridSize / 2) { imgNumber = 0; } imageName = imgsArr[imgNumber] as string; int resId = Resources.GetIdentifier(imageName, "drawable", PackageName); imgTile.SetImageResource(resId); imgTile.LayoutParameters = tileParams; imgTile.SetOnTouchListener(this); tilesArr.Add(imgTile); gameGridLayout.AddView(imgTile); imgNumber++; } } }
private void CreateLayout() { // Create a new layout for the entire page. LinearLayout layout = new LinearLayout(this) { Orientation = Orientation.Vertical }; // Create a new layout for the toolbar (buttons). GridLayout toolbar = new GridLayout(this) { RowCount = 2, ColumnCount = 2, AlignmentMode = GridAlign.Margins }; // Create a button to reset the route display, add it to the toolbar. _facilityButton = new Button(this) { Text = "Place Facility" }; _facilityButton.Click += PlaceFacilityButtonClick; toolbar.AddView(_facilityButton); // Create a button to reset the route display, add it to the toolbar. _barrierButton = new Button(this) { Text = "Draw Barrier" }; _barrierButton.Click += DrawBarrierButtonClick; toolbar.AddView(_barrierButton); // Create a button to reset the route display, add it to the toolbar. _serviceAreasButton = new Button(this) { Text = "Show Service Areas" }; _serviceAreasButton.Click += ShowServiceAreasButtonClick; toolbar.AddView(_serviceAreasButton); // Create a button to reset the route display, add it to the toolbar. _resetButton = new Button(this) { Text = "Reset" }; _resetButton.Click += ResetClick; toolbar.AddView(_resetButton); // Add the toolbar to the layout layout.AddView(toolbar); // Add the map view to the layout layout.AddView(_myMapView); // Show the layout in the app SetContentView(layout); }
private GridLayout CreateGridWithViews(Context context, Button bundleButton, ImageView bundleImage) { GridLayout gridView = new GridLayout(context); gridView.AlignmentMode = GridAlign.Bounds; gridView.ColumnCount = 2; gridView.Orientation = GridOrientation.Horizontal; gridView.UseDefaultMargins = true; gridView.AddView(bundleImage, this.imagesHeight, this.imagesHeight); gridView.AddView(bundleButton); return(gridView); }
private void PopulateGridLayoutByChallenges(GridLayout grid, Context ctx, IEnumerable <Challenge> challenges) { foreach (var challenge in challenges) { var chLayout = new LinearLayout(ctx) { Orientation = Orientation.Vertical }; var imageView = new ImageView(ctx); var challengeImage = BitmapFactory.DecodeFile(challenge.ImageUri.LocalPath); imageView.SetImageBitmap(challengeImage); var textView = new TextView(ctx) { Gravity = GravityFlags.Center, Text = challenge.Names[0].Name.Replace(' ', '\n') }; chLayout.AddView(imageView); chLayout.AddView(textView); chLayout.Click += (sender, args) => { ChallengeSelected.Invoke(this, AppState.State.Instance.Challenges.ToList().IndexOf(challenge)); }; grid.AddView(chLayout); } }
public async Task Display(string message, Xamarin.Forms.ImageSource imageSource) { var handler = GetHandler(imageSource); var context = (Activity)Xamarin.Forms.Forms.Context; var image = await handler.LoadImageAsync(imageSource, context); if (image != null) { var imageView = new ImageView(context); imageView.SetImageBitmap(image); var layout = new GridLayout(context); layout.AddView(imageView); layout.SetBackgroundResource(KingTranslator.Droid.Resource.Color.webBG); var builder = new AlertDialog.Builder(context).SetView(layout).SetCancelable(true); if (!string.IsNullOrWhiteSpace(message)) { builder.SetMessage(message); } builder.Create().Show(); } else { throw new ArgumentNullException("Image is null"); } }
public void SetWordList(IEnumerable <FoundWord> lstWords) { _grdWordList.RemoveAllViews(); int ndx = 0; if (lstWords != null && _mainActivity._chkShowWordList.Checked) { foreach (var item in lstWords) { LetterWheelLayout.GetColorFromFoundWordType(item.foundWordType, out var forecolr, out var backColr); var tv = new TextView(_mainActivity) { Text = item.word, }; tv.SetBackgroundColor(backColr); tv.SetTextColor(forecolr); tv.Click += (o, e) => { MainActivity.DoLookupOnlineDictionary(tv.Text); }; var x = ndx / _grdWordList.RowCount; var y = ndx - x * _grdWordList.RowCount; var parms = new GridLayout.LayoutParams(GridLayout.InvokeSpec(y), GridLayout.InvokeSpec(x)); tv.LayoutParameters = parms; parms.RightMargin = 5; // ((GridLayout.LayoutParams)(tv.LayoutParameters)).RightMargin = 2; _grdWordList.AddView(tv); ndx++; } } _mainActivity._txtWordListLen.Text = ndx.ToString(); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.Lecture); GridLayout grd = FindViewById <GridLayout>(Resource.Id.lecturegrid); Android.Util.DisplayMetrics displayMetrics = new DisplayMetrics(); WindowManager.DefaultDisplay.GetMetrics(displayMetrics); int width = displayMetrics.WidthPixels / 4; for (int i = 1; i <= 16; i++) { Button lbtn = new Button(this) { Text = i.ToString() }; lbtn.Click += (sender, evt) => { string html = string.Empty; string url = @"http://party4bread.xyz/BNCD/getactivelecture.php?no=" + (sender as Button).Text; HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url); request.AutomaticDecompression = DecompressionMethods.GZip; using (HttpWebResponse response = (HttpWebResponse)request.GetResponse()) using (System.IO.Stream stream = response.GetResponseStream()) using (System.IO.StreamReader reader = new StreamReader(stream)) html = reader.ReadToEnd(); string msg = html; if (!msg.Contains("http")) { Toast.MakeText(this, msg, ToastLength.Long).Show(); } else { Intent intent = new Intent(this, typeof(MainActivity)); intent.PutExtra("lecture", msg); StartActivity(intent); } }; GridLayout.LayoutParams lp = new GridLayout.LayoutParams(); //lp.SetGravity(GravityFlags.Fill); lp.Width = width; lp.Height = width; lp.SetMargins(0, 0, 0, 0); int rbpar = i * 16 < 255? i * 16:255, gpar = rbpar == 255?255 - i:255; GradientDrawable gd = new GradientDrawable(); gd.SetStroke(5, new Android.Graphics.Color(0, 0, 0)); gd.SetCornerRadius(10); gd.SetColor(new Android.Graphics.Color(rbpar, gpar, rbpar)); lbtn.SetBackgroundDrawable(gd); lbtn.LayoutParameters = lp; rbpar = i * 17 < 255 ? i * 17 : 255; gpar = rbpar == 255 ? 255 - i * 2 : 255; grd.SetBackgroundColor(new Android.Graphics.Color(rbpar, gpar, rbpar)); grd.AddView(lbtn); } // Create your application here }
public void PopulateMatrix(int totalColumns, int totalRows) { gridLayoutMatrix.ColumnCount = totalColumns; gridLayoutMatrix.RowCount = totalRows; //gridLayoutMatrix.UseDefaultMargins = true; var matrixCordinateSystem = new Dictionary <RelativeLayout, int[]>() { }; for (int i = 0; i < totalRows; i++) { for (int j = 0; j < totalRows; j++) { RelativeLayout relativeLayout = new RelativeLayout(BaseContext); relativeLayout.SetMinimumWidth(40); relativeLayout.SetMinimumHeight(40); relativeLayout.Background = new Android.Graphics.Drawables.ColorDrawable(new Android.Graphics.Color(0, 0, 0, 255)); relativeLayout.Touch += async(sender, e) => { ((RelativeLayout)relativeLayout).Background = new Android.Graphics.Drawables.ColorDrawable(new Android.Graphics.Color(seekBarRed.Progress, seekBarGreen.Progress, seekBarBlue.Progress, 255)); //System.Diagnostics.Debug.WriteLine($"CORDINATES: {matrixCordinateSystem[((RelativeLayout)sender)][0]}, {matrixCordinateSystem[((RelativeLayout)sender)][1]}|"); ((DrawPixelCommand)displayCommand).X = matrixCordinateSystem[((RelativeLayout)relativeLayout)][1]; ((DrawPixelCommand)displayCommand).Y = matrixCordinateSystem[((RelativeLayout)relativeLayout)][0]; UpdateDisplay(displayCommand); UpdateDisplayCommandEditTextView(); }; matrixCordinateSystem.Add(relativeLayout, new int[] { i, j }); gridLayoutMatrix.AddView(relativeLayout); } } }
private View GetCircularVideoPlayer() { LinearLayout linearLayout = new LinearLayout(this.context) { Orientation = Orientation.Vertical }; this.videoPlayerProgressBar = new SfCircularProgressBar(this.context) { Progress = 100, ShowProgressValue = true, TrackInnerRadius = 0f, IndicatorOuterRadius = 0.7f, IndicatorInnerRadius = 0.65f, AnimationDuration = 10000, LayoutParameters = this.layoutParams }; GridLayout.LayoutParams gridLayoutParams = new GridLayout.LayoutParams { RowSpec = GridLayout.InvokeSpec(0), ColumnSpec = GridLayout.InvokeSpec(0) }; GridLayout custContentLayout = new GridLayout(this.context); this.playButton = new ImageButton(this.context) { Visibility = ViewStates.Invisible }; this.playButton.SetImageResource(Resource.Drawable.SfProgressPlay); this.playButton.SetBackgroundColor(Color.ParseColor("#00FFFFFF")); this.playButton.Click += this.PlayButton_Click; custContentLayout.AddView(this.playButton, gridLayoutParams); this.pauseButton = new ImageButton(this.context); this.pauseButton.SetImageResource(Resource.Drawable.SfProgressPause); this.pauseButton.SetBackgroundColor(Color.ParseColor("#00FFFFFF")); this.pauseButton.Click += this.PauseButton_Click; custContentLayout.AddView(this.pauseButton, gridLayoutParams); this.videoPlayerProgressBar.Content = custContentLayout; this.videoPlayerProgressBar.ValueChanged += this.ProgressBar_ValueChanged100; linearLayout.AddView(this.videoPlayerProgressBar); return(linearLayout); }
private void MakeTiles() { tileWidth = gameViewWidth / 4; tilesArray = new ArrayList(); coordsArray = new ArrayList(); int counter = 1; #region MyRegion for (int h = 0; h < 4; h++) { for (int v = 0; v < 4; v++) { MyTextView textTile = new MyTextView(this); GridLayout.Spec rowSpec = GridLayout.InvokeSpec(h); GridLayout.Spec colSpec = GridLayout.InvokeSpec(v); GridLayout.LayoutParams tileLayoutParams = new GridLayout.LayoutParams(rowSpec, colSpec); // 0 1 2 3 v/x // 0 T T T T // 1 T T T T // 2 T T T T // 3 T T T T textTile.Text = counter.ToString(); textTile.SetTextColor(Color.Black); textTile.TextSize = 40; textTile.Gravity = GravityFlags.Center; tileLayoutParams.Width = tileWidth - 10; tileLayoutParams.Height = tileWidth - 10; tileLayoutParams.SetMargins(5, 5, 5, 5); textTile.LayoutParameters = tileLayoutParams; textTile.SetBackgroundColor(Color.Green); Point thisLoc = new Point(v, h); coordsArray.Add(thisLoc); textTile.xPos = thisLoc.X; textTile.yPos = thisLoc.Y; textTile.Touch += TextTile_Touch; tilesArray.Add(textTile); mainLayout.AddView(textTile); counter++; } } #endregion mainLayout.RemoveView((MyTextView)tilesArray[15]); tilesArray.RemoveAt(15); }
void FillSalas() { GridLayout glSalas = FindViewById <GridLayout>(Resource.Id.glSalas); salas.AsParallel().ToList().ForEach(sala => { View SalaView = LayoutInflater.Inflate(Resource.Layout.SalaSeleccionLayout, null, true); SalaView.FindViewById <ImageView>(Resource.Id.ivSala).SetImageResource(Resources.GetIdentifier(string.Format("s{0}{1}", sala.Sala_Id, sala.Sala_Nivel), "mipmap", PackageName)); SalaView.FindViewById <TextView>(Resource.Id.lblNombre).Text = sala.Sala_Descripcion; SalaView.FindViewById <TextView>(Resource.Id.lblNivel).Text = string.Format("Nivel {0}", sala.Sala_Nivel); if (Tipo == (int)TipoSalaReunionFlujo.Horario) { SalaView.FindViewById <TextView>(Resource.Id.lblCreditos).Text = string.Format("{0} Créditos", cantidad_creditos); } else { SalaView.FindViewById <TextView>(Resource.Id.lblCreditos).Visibility = ViewStates.Gone; } SalaView.Click += delegate { if (Tipo == (int)TipoSalaReunionFlujo.Sala) { Intent intent = new Intent(this, typeof(ReservacionHorariosActivity)); intent.PutExtra("Tipo", (int)TipoSalaReunionFlujo.Sala); intent.PutExtra("sala_id", sala.Sala_Id); StartActivity(intent); } else if (Tipo == (int)TipoSalaReunionFlujo.Horario) { Intent intent = new Intent(this, typeof(ReservacionConfirmarActivity)); intent.PutExtra("Tipo", (int)TipoSalaReunionFlujo.Sala); intent.PutExtra("fecha_seleccionada", fecha_seleccionada); intent.PutExtra("hora_inicio", hora_inicio); intent.PutExtra("hora_fin", hora_fin); intent.PutExtra("cantidad_personas", cantidad_personas); intent.PutExtra("cantidad_creditos", cantidad_creditos); intent.PutExtra("sala_id", sala.Sala_Id); StartActivity(intent); } else { Intent intent = new Intent(this, typeof(ReservacionSalaOpcionesActivity)); intent.PutExtra("Opcion", "Editar"); intent.PutExtra("Reservacion_Id", reservacion_id); intent.PutExtra("sala_id", sala.Sala_Id); intent.PutExtra("fecha_seleccionada", fecha_seleccionada); intent.PutExtra("hora_inicio", hora_inicio); intent.PutExtra("hora_fin", hora_fin); intent.PutExtra("cantidad_personas", cantidad_personas); intent.PutExtra("cantidad_creditos", cantidad_creditos); StartActivity(intent); } Finish(); }; glSalas.AddView(SalaView); }); }
void GenerateCardsFromDatabase() { string currentWallet = DataLayer.GetCurrentWallet(); List <Coin> coins = DataLayer.GetCoinObjects(currentWallet); foreach (Coin c in coins) { CardView cardView = CreateCardViewScheme1(c.Symbol, c.Description, "", "", "", System.String.Format("{0:n}", c.NumberOfCoins), "", Color.Green, Resource.Drawable.ic_arrow_drop_up_green_500_18dp); cardViewDict.Add(c.Symbol, cardView); cardViewGridLayout.AddView(cardView); UpdateCoinBalance(c.Symbol, c.PrivateKey); } }
public override View GetPropertyWindowLayout(Android.Content.Context context) { gridlayout = new GridLayout(context); gridlayout.SetPadding(20, 20, 20, 20); gridlayout.RowCount = 2; gridlayout.ColumnCount = 2; conditionTextView = new TextView(context); conditionTextView.Text = "Select the condition to filter"; columnTextView = new TextView(context); columnTextView.Text = "Select the column to filter"; groupTextView = new TextView(context); groupTextView.Text = "Group by"; columnDropdown = new Spinner(context, SpinnerMode.Dialog); var columnAdapter = new ArrayAdapter(context, Android.Resource.Layout.SimpleSpinnerItem); var properties = typeof(BookDetails).GetProperties(); columnAdapter.Add("All Columns"); foreach (var propertyInfo in properties) { if (propertyInfo.Name != "CustomerImage") { columnAdapter.Add(propertyInfo.Name); } } columnAdapter.SetDropDownViewResource(Android.Resource.Layout.SimpleSpinnerDropDownItem); columnDropdown.Adapter = columnAdapter; conditionDropdown = new Spinner(context, SpinnerMode.Dialog); condtionAdapter = new ArrayAdapter(context, Android.Resource.Layout.SimpleSpinnerItem); condtionAdapter.SetDropDownViewResource(Android.Resource.Layout.SimpleSpinnerDropDownItem); conditionDropdown.Adapter = condtionAdapter; columnDropdown.ItemSelected += new EventHandler <AdapterView.ItemSelectedEventArgs>(OnColumnSelected); conditionDropdown.ItemSelected += OnConditionSelected; gridlayout.LayoutParameters = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MatchParent, LinearLayout.LayoutParams.WrapContent); gridlayout.AddView(columnTextView, LinearLayout.LayoutParams.WrapContent, (int)(30 * context.Resources.DisplayMetrics.Density)); gridlayout.AddView(columnDropdown); gridlayout.AddView(conditionTextView, LinearLayout.LayoutParams.WrapContent, (int)(30 * context.Resources.DisplayMetrics.Density)); gridlayout.AddView(conditionDropdown); return(gridlayout); }
// void rundb() // { // FirebaseOptions firebaseOptions = new FirebaseOptions.Builder().SetApiKey(" AIzaSyBQev9ULBFWqD31zfTr8ovFSGlURNDM2S4 ").SetDatabaseUrl("https://eticaret-feebb.firebaseio.com/").SetApplicationId("eticaret-feebb").Build(); // FirebaseApp firebaseApp = FirebaseApp.InitializeApp(this, firebaseOptions); // FirebaseDatabase firebaseDatabase = FirebaseDatabase.GetInstance(firebaseApp); // DatabaseReference databaseReference = firebaseDatabase.Reference.Database.Reference; // databaseReference.AddChildEventListener(this); // databaseReference.AddValueEventListener(this); // databaseReference.Child("Person").SetValue(new Person() { name = "mali", age = 20 }).AddOnCompleteListener(this).AddOnFailureListener(this); // } //async Task RunAsycn() // { // FirebaseOptions firebaseOptions = new FirebaseOptions.Builder().SetApiKey(" AIzaSyBQev9ULBFWqD31zfTr8ovFSGlURNDM2S4 ").SetDatabaseUrl("https://eticaret-feebb.firebaseio.com/").SetApplicationId("eticaret-feebb").Build(); // FirebaseApp firebaseApp = FirebaseApp.InitializeApp(this, firebaseOptions); // FirebaseDatabase firebaseDatabase = FirebaseDatabase.GetInstance(firebaseApp); // DatabaseReference databaseReference = firebaseDatabase.Reference.Database.Reference; // databaseReference.AddChildEventListener(this); // databaseReference.AddValueEventListener(this); // // databaseReference.Push().Child("Person").SetValue(new Person() { name = "mali", age = 20 }).AddOnCompleteListener(this).AddOnFailureListener(this); // await databaseReference.Child("Person").SetValueAsync(new Person() { name = "mali", age = 20 }); // //databaseReference.NotifyAll(); // } #endregion void CreateItems(TableQuery <Product> products) { //clear all views on the grid layout so I can create what I want to create mainLayout.RemoveAllViews(); //read the database and get the image and product id and create all for (int i = 0; i < products.Count(); i++) { LinearLayout linearLayout = (LinearLayout)LayoutInflater.Inflate(Resource.Layout.basicCart, null); Button button = linearLayout.FindViewById <Button>(Resource.Id.cartShowButton); button.Tag = products.ElementAt(i).ProductID; button.Click += Button_Click; ImageView image = linearLayout.FindViewById <ImageView>(Resource.Id.cartImage); image.SetImageDrawable(GetDrawable(products.ElementAt(i).ProductImage)); #region No need for now //linearLayout.LayoutParameters = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MatchParent, LinearLayout.LayoutParams.MatchParent); //linearLayout.LayoutParameters.Width = DpToPixel(this, 180); //linearLayout.LayoutParameters.Height = DpToPixel(this, 150); //linearLayout.Orientation = Orientation.Vertical; //ImageView image = View.Inflate(this,) //image.LayoutParameters = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MatchParent, LinearLayout.LayoutParams.MatchParent); //image.LayoutParameters.Width = DpToPixel(this, 154); //image.LayoutParameters.Height = DpToPixel(this, 93); //image.SetImageResource(Resource.Drawable.sportShoe); //image.SetForegroundGravity(GravityFlags.Center); //linearLayout.AddView(image); //Button button = new Button(this); //button.LayoutParameters = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MatchParent, LinearLayout.LayoutParams.MatchParent); ////set buttons tag to its product id so when we click the button we can find the product that ////we are looking for //button.LayoutParameters.Width = DpToPixel(this, 90); //button.LayoutParameters.Height = DpToPixel(this, 35); //button.Text = "VIEW"; //Drawable img = GetDrawable(Resource.Drawable.search); // //img.Wait(); //img.SetBounds(0, 0, 100, 80); //button.SetCompoundDrawables(img, null, null, null); //button.CompoundDrawableTintList = GetColorStateList(Resource.Color.white); //button.Gravity = GravityFlags.CenterHorizontal; //button.SetBackgroundColor(Android.Graphics.Color.ParseColor("#FFAA66CC")); //button.TextAlignment = TextAlignment.Center; //button.SetTextColor(GetColorStateList(Resource.Color.white)); //button.Tag = i; //button.Click += Button_Click; //linearLayout.AddView(button); //gridLayout.Wait(); #endregion mainLayout.AddView(linearLayout); } }
public void ShowActionSheet(string title, string message, string cancel, string destructive, Action <string> callback, params string[] buttons) { Utilities.Dispatch(() => { var context = GetActivityContext(); var dialog = new AlertDialog.Builder(context); if (!string.IsNullOrEmpty(title)) { dialog.SetTitle(title); } if (!string.IsNullOrEmpty(message)) { dialog.SetMessage(message); } var grid = new GridLayout(context) { RowCount = buttons.Length, ColumnCount = 1 }; grid.SetPadding(20, 0, 20, 30); var texts = new List <string>(buttons ?? new string[0]); texts.ForEach(text => grid.AddView(GetActionSheetButton(context, text, callback))); if (!string.IsNullOrEmpty(destructive)) { var destructiveButton = GetActionSheetButton(context, destructive, callback); destructiveButton.SetTextColor(Color.Red); grid.RowCount++; grid.AddView(destructiveButton); } if (!string.IsNullOrEmpty(cancel)) { var cancelButton = GetActionSheetButton(context, cancel, callback); cancelButton.SetTextColor(Color.Black); grid.RowCount++; grid.AddView(cancelButton); } dialog.SetView(grid); _Dialog = dialog.Show(); }); }
public CustomView(Context context) : base(context) { this.SetPadding(25, 25, 25, 25); this.SetBackgroundColor(Color.ParseColor("#FFFFFF")); this.ColumnCount = 3; this.RowCount = 1; image1 = new ImageView(context); image1.SetPadding(0, 10, 0, 10); image2 = new ImageView(context); image2.SetPadding(0, (int)(15 * Resources.DisplayMetrics.Density), 0, (int)(15 * Resources.DisplayMetrics.Density)); Label1 = new TextView(context); Label1.Gravity = GravityFlags.Start; Label1.Alpha = 221; Label1.SetTextColor(Color.Black); Label1.TextSize = 20; Label2 = new TextView(context); Label2.Gravity = GravityFlags.Start; Label2.Alpha = 137; Label2.TextSize = 16; Label2.SetTextColor(Color.Gray); DetailsLayout = new GridLayout(context); DetailsLayout.RowCount = 4; DetailsLayout.ColumnCount = 1; DetailsLayout.AddView(Label1); DetailsLayout.AddView(Label2); DetailsLayout.SetPadding((int)(20 * this.Resources.DisplayMetrics.Density), (int)(5 * this.Resources.DisplayMetrics.Density), 0, 0); if (MainActivity.IsTablet) { this.AddView(image1, (int)(70 * this.Resources.DisplayMetrics.Density), (int)(70 * this.Resources.DisplayMetrics.Density)); } else { this.AddView(image1, (int)(50 * this.Resources.DisplayMetrics.Density), (int)(50 * this.Resources.DisplayMetrics.Density)); } this.AddView(DetailsLayout, Resources.DisplayMetrics.WidthPixels - (int)(120 * Resources.DisplayMetrics.Density) - 70, ViewGroup.LayoutParams.MatchParent); this.AddView(image2, (int)(50 * this.Resources.DisplayMetrics.Density), (int)(50 * this.Resources.DisplayMetrics.Density)); }
void createModalView <T>(T dataRow) { Type m_tipo = null; PropertyInfo[] m_propiedades = null; m_tipo = dataRow.GetType(); m_propiedades = m_tipo.GetProperties(); ScrollView scroll = new ScrollView(this); scroll.LayoutParameters = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent); GridLayout contentModal = new GridLayout(this); contentModal.RowCount = m_propiedades.Count(); contentModal.ColumnCount = 2; GridLayout.LayoutParams hola = new GridLayout.LayoutParams(); hola.SetMargins(10, 10, 10, 10); hola.SetGravity(GravityFlags.Center); contentModal.LayoutParameters = hola; foreach (PropertyInfo propiedad in m_propiedades) { TextView campoNombreModal = new TextView(this); campoNombreModal.Text = propiedad.Name; campoNombreModal.TextAlignment = TextAlignment.Center; TextView campoValorModal = new TextView(this); campoValorModal.Text = propiedad.GetValue(dataRow, null).ToString(); campoValorModal.TextAlignment = TextAlignment.Center; contentModal.AddView(campoNombreModal); contentModal.AddView(campoValorModal); } scroll.AddView(contentModal); AlertDialog.Builder ventanaModalAlert = new AlertDialog.Builder(this); ventanaModalAlert.SetView(scroll); ventanaModalAlert.SetNegativeButton("Aceptar", delegate { }); ventanaModalAlert.Create().Show(); }
private async void btStop_Click(object sender, EventArgs e) { await mediaPlayer?.StopAsync(); mediaPlayer?.Dispose(); mediaPlayer = null; // clear screen workaround pnScreen.RemoveView(videoView); pnScreen.AddView(videoView); }
private async void btStop_Click(object sender, EventArgs e) { tmPosition.Stop(); await _player.StopAsync(); await _player.CloseAsync(); // clear screen workaround pnScreen.RemoveView(videoView); pnScreen.AddView(videoView); }
public override View GetPropertyWindowLayout(Context context) { gridlayout = new GridLayout(context); gridlayout.SetPadding(20, 20, 20, 20); gridlayout.RowCount = 2; gridlayout.ColumnCount = 2; groupTextView = new TextView(context); groupTextView.Text = "Sort by"; groupDropdown = new Spinner(context, SpinnerMode.Dialog); var groupAdapter = new ArrayAdapter(context, Android.Resource.Layout.SimpleSpinnerItem); groupAdapter.SetDropDownViewResource(Android.Resource.Layout.SimpleSpinnerDropDownItem); groupAdapter.Add("Ascending"); groupAdapter.Add("Descending"); groupDropdown.Adapter = groupAdapter; groupDropdown.ItemSelected += GroupDropdown_ItemSelected; gridlayout.AddView(groupTextView, LinearLayout.LayoutParams.WrapContent, (int)(30 * context.Resources.DisplayMetrics.Density)); gridlayout.AddView(groupDropdown); return(gridlayout); }
private void TilesMethod() { tileWidth = viewGameWidth / 4; tileArr = new ArrayList(); coordsTile = new ArrayList(); int counter = 1; for (int rows = 0; rows < 4; rows++) { for (int colls = 0; colls < 4; colls++) { MyTextView txtTile = new MyTextView(this); txtTile.Text = counter.ToString(); txtTile.SetTextColor(Color.White); txtTile.Gravity = GravityFlags.Center; txtTile.TextSize = 30; GridLayout.Spec rowSpec = GridLayout.InvokeSpec(txtTile.xPos); GridLayout.Spec collSpec = GridLayout.InvokeSpec(txtTile.yPos); GridLayout.LayoutParams tileLayoutParams = new GridLayout.LayoutParams(rowSpec, collSpec); tileLayoutParams.Width = tileWidth - 10; tileLayoutParams.Height = tileWidth - 10; tileLayoutParams.SetMargins(6, 6, 6, 6); txtTile.LayoutParameters = tileLayoutParams; txtTile.SetBackgroundColor(Color.Green); Point point = new Point(colls, rows); coordsTile.Add(point); txtTile.xPos = point.X; txtTile.yPos = point.Y; txtTile.Touch += TxtTile_Touch; tileArr.Add(txtTile); gridLayout.AddView(txtTile); counter++; } } gridLayout.RemoveView((MyTextView)tileArr[15]); tileArr.RemoveAt(15); }
private void AddSymbol(Symbol symbol) { var sd = new SymbolDisplay(this) { Symbol = symbol }; sd.SetMaxHeight(40); var p = new GridLayout.LayoutParams(); p.SetGravity(GravityFlags.Center); sd.LayoutParameters = p; rootLayout.AddView(sd); }
private void Populate() { foreach (Model.Movie movie in Schedule.Movies) { RelativeLayout container = CreateMovieContainer(); ImageView poster = CreatePosterContainer(movie.BitmapPoster); TextView title = CreateTitle(movie.Title); container.AddView(poster); container.AddView(title); container.Click += Movie_Click; Window.EnterTransition.AddTarget(container); _root.AddView(container); } }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); // Create your application here GridLayout layout = new GridLayout(this); layout.ColumnCount = 1; layout.RowCount = 5; createTopic = new Button(this); createTopic.Text = "Create Topic"; createTopic.Click += createTopic_Click; layout.AddView(createTopic); emailText = new EditText(this); emailText.Text = ""; layout.AddView(emailText); subscribe = new Button(this); subscribe.Enabled = false; subscribe.Text = "Subscribe to Topic"; subscribe.Click += subscribe_Click; layout.AddView(subscribe); deleteTopic = new Button(this); deleteTopic.Click += deleteTopic_Click; deleteTopic.Enabled = false; deleteTopic.Text = "Delete Topic"; layout.AddView(deleteTopic); statusText = new TextView(this); layout.AddView(statusText); SetContentView(layout); }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); // Create your application here GridLayout layout = new GridLayout(this); layout.ColumnCount = 1; layout.RowCount = 5; createButton = new Button(this); createButton.Text = "Create Bucket"; createButton.Click += createButton_Click; layout.AddView(createButton); uploadButton = new Button(this); uploadButton.Text = "Upload Image"; uploadButton.Click += uploadButton_Click; uploadButton.Enabled = false; layout.AddView(uploadButton); deleteButton = new Button(this); deleteButton.Text = "Delete Bucket"; deleteButton.Click += deleteButton_Click; deleteButton.Enabled = false; layout.AddView(deleteButton); statusText = new TextView(this); layout.AddView(statusText); progressBar = new ProgressBar(this); progressBar.Visibility = ViewStates.Invisible; layout.AddView(progressBar); SetContentView(layout); }
/// <summary> /// Basic constructor /// </summary> /// <param name="context"></param> public SettingsLayout(MainActivity context) : base(context) { this.Orientation = GridOrientation.Vertical; Button heightButton = new Button(context) { Text = "Sets the height of every button in pixels. Current: " + Convert.ToString(context.Settings.ExpectedHeight), }; heightButton.SetHeight(context.Settings.ExpectedHeight); heightButton.SetWidth(context.Settings.ExpectedWidth); heightButton.Click += (object sender, EventArgs args) => { AlertDialog.Builder dialog = new AlertDialog.Builder(context); dialog.SetTitle("Button height"); GridLayout num = new GridLayout(dialog.Context); EditText n = new EditText(dialog.Context) { InputType = InputTypes.ClassNumber, Text = Convert.ToString(context.Settings.ExpectedHeight) }; num.AddView(n); dialog.SetView(num); dialog.SetPositiveButton("OK!", (object s, DialogClickEventArgs a) => { if (n.Text != "") { context.Settings.ExpectedHeight = Convert.ToInt32(n.Text); context.SaveSettings(); } }); dialog.Create().Show(); }; this.AddView(heightButton); Button reseedButton = new Button(context) { Text = "Reseeds the generator for random numbers using the current time." }; reseedButton.SetHeight(context.Settings.ExpectedHeight); reseedButton.SetWidth(context.Settings.ExpectedWidth); reseedButton.Click += (object sender, EventArgs args) => Dice.Reseed(); this.AddView(reseedButton); }
//--->TERMINAN COSAS DE SELECCIONAR IMAGEN DE LA CAMARA<---// //INICIA PROCESAR IMAGENES public void ProcesarImagenes (GridLayout imgcomprev, int limite, TextView imgrestantes){ if(imgcount<limite){ GetImage(((b, p) => { int countimage = p.Count; Log.Debug("GetImage","Imagenes en el list: "+countimage); int imgcount2=imgcount+countimage; Log.Debug("GetImage","Imagenes totales: "+imgcount2); if(imgcount2>limite){ //int total = limite-imgcount; var fabee = FindViewById<CoordinatorLayout> (Resource.Id.snackbarPosition); Snackbar .Make (fabee, "No puedes publicar mas de "+limite+" imágenes!", Snackbar.LengthLong) .SetAction ("Ok", (view) => { }) .Show (); }else{ //ya aqui se hace lo de poner cada imagen imgcount=imgcount2; Log.Debug("GetImage","Nuevo imgcount: "+imgcount); for(int i=0; i<countimage; i++){ //filenameres= p[i].Substring (p[i].LastIndexOf ("/") + 1); //fileextres= filenameres.Substring (filenameres.LastIndexOf(".")+1); //Si por algún acaso la memoria no ha sido liberada, la liberamos primero. if (imagencomentario != null && !imagencomentario.IsRecycled) { imagencomentario.Recycle(); imagencomentario = null; } Java.IO.File f = new Java.IO.File(p[i]); stream = this.ContentResolver.OpenInputStream(Android.Net.Uri.FromFile(f)); imagencomentario=BitmapFactory.DecodeStream(stream); //POR AHORA VAMOS A QUITAR ESTO PARA QUE LO HAGA MAS RAPIDO Y DEJAMOS QUE EL SERVIDOR SE ENCARGUE /* try{ Android.Media.ExifInterface ei = new Android.Media.ExifInterface(p[i]); var orientation= ei.GetAttributeInt(Android.Media.ExifInterface.TagOrientation, -1); Log.Debug("GetImageCamera","El orientation es: "+orientation); if(orientation==1){ //No hagas nada, si está bien la imagen. No tiene caso .-. }else{ Log.Debug("Orientation", "Inicia Mutable"); Bitmap mutable; Canvas cnv; Matrix matrix; Log.Debug("Orientation", "Termina Mutable"); Log.Debug("Orientation", "Inicia Switch"); switch(orientation){ case 6: //90 grados mutable = imagencomentario.Copy(Bitmap.Config.Argb8888, true); cnv = new Canvas(mutable); matrix = new Matrix(); Log.Debug("Orientation", "90 Grados"); matrix.PostRotate(90); imagencomentario=Bitmap.CreateBitmap(mutable, 0, 0, imagencomentario.Width, imagencomentario.Height, matrix, true); break; case 3: //180 grados mutable = imagencomentario.Copy(Bitmap.Config.Argb8888, true); cnv = new Canvas(mutable); matrix = new Matrix(); Log.Debug("Orientation", "180 Grados"); matrix.PostRotate(180); imagencomentario=Bitmap.CreateBitmap(mutable, 0, 0, imagencomentario.Width, imagencomentario.Height, matrix, true); break; case 8: //270 grados mutable = imagencomentario.Copy(Bitmap.Config.Argb8888, true); cnv = new Canvas(mutable); matrix = new Matrix(); Log.Debug("Orientation", "270 Grados"); matrix.PostRotate(270); imagencomentario=Bitmap.CreateBitmap(mutable, 0, 0, imagencomentario.Width, imagencomentario.Height, matrix, true); break; default: Log.Debug("Orientation", "0 Grados (0 360, como se quiera ver :P)"); //0 grados //No hagas nada break; }; Log.Debug("Orientation", "Termina Switch"); }//ELSE orientation = 1 }catch(Exception ex){ Log.Debug("Orientation", "ERROR! Posiblemente no hay EXIF: "+ex); } */ if(imagencomentario!=null){ //Toast.MakeText(this, "Si se creó el Bitmap!!!", ToastLength.Long).Show(); //Lo añadimos a la lista //Bitmap tmp = imagencomentario; Log.Debug("FOSSBYTES","Inicia conversión a bytes!"); byte[] tmp2 = PathToByte2(p[i]); Log.Debug("FOSSBYTES","Termina conversión a bytes!"); fossbytes.Add(tmp2); //Toast.MakeText(this, "Elementos en lista: "+contenedorimagenes.Count, ToastLength.Long).Show(); //aqui haremos el img //Creamos el imageview con sus parámetros ImageView prev = new ImageView(this); imgcomprev.AddView(prev); GridLayout.LayoutParams lp = new GridLayout.LayoutParams(); lp.SetMargins(15,15,0,15); lp.Width=130; lp.Height=130; prev.LayoutParameters=lp; prev.SetScaleType(ImageView.ScaleType.CenterCrop); prev.SetImageBitmap(Bitmap.CreateScaledBitmap(imagencomentario, 175, 175, false)); //prev.StartAnimation(bounce); //imgcount++; //Liberamos la memoria Inmediatamente! if (imagencomentario != null && !imagencomentario.IsRecycled) { imagencomentario.Recycle(); imagencomentario = null; } //Mala idea, esto causó que tronara .-. si lo voy a hacer pero cuando no tenga que usarlo }else{//por si algun acaso intenta procesar una ruta null var fabee = FindViewById<CoordinatorLayout> (Resource.Id.snackbarPosition); Snackbar .Make (fabee, "Ocurrió un error. Por favor intenta con una imágen diferente", Snackbar.LengthLong) .SetAction ("Ok", (view) => { }) .Show (); break; } }//TERMINA EL FOR PARA CADA IMAGEN int restantes=limite-imgcount; if(restantes==0){ imgrestantes.Text="¡Excelente!"; }else{ imgrestantes.Text="Puedes cargar "+restantes+" imágenes más!"; } }//TERMINA EL ELSE DE COMPROBAR SI HAY MAS IMAGENES DE LAS QUE SE PUEDEN CARGAR }));//GETIMAGE }else{ var fabee = FindViewById<CoordinatorLayout> (Resource.Id.snackbarPosition); Snackbar .Make (fabee, "Solo puedes subir hasta 3 imágenes!", Snackbar.LengthLong) .SetAction ("Ok", (view) => { }) .Show (); }//ELSE COUNTIMAGES < 3 }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); //游戏开始 ImageView imgStart = FindViewById<ImageView>(Resource.Id.imgStart); imgStart.Click += delegate { var intent = new Intent(this, typeof(GameActivity)); intent.PutExtra("game", GameIndex); StartActivityForResult(intent, 0); Finish(); }; //游戏退出 ImageView imgExit = FindViewById<ImageView>(Resource.Id.imgExit); imgExit.Click += delegate { Finish(); }; //绑定关卡列表 glBarriers = FindViewById<GridLayout>(Resource.Id.glBarriers); //BarrierList = _db.QueryAllBarriers(); BarrierList = new List<Barrier>(); var names = Resources.GetStringArray(Resource.Array.barrier_names); var titles = Resources.GetStringArray(Resource.Array.barrier_titles); for (int i = 0; i < names.Length; i++) { var barrier = DB.QueryBarrier(i); if (barrier == null) { barrier = new Barrier() { Id = i, Title = titles[i], Name = names[i], Star = 0, State = (i == 0 ? true : false), NextID = (i == names.Length - 1) ? 0 : (i + 1) }; DB.Insert(barrier); } BarrierList.Add(barrier); LinearLayout linear = new LinearLayout(this); GridLayout.LayoutParams g = new GridLayout.LayoutParams(); g.Width = GridLayout.LayoutParams.WrapContent; g.Height = GridLayout.LayoutParams.WrapContent; if (Resources.DisplayMetrics.Density == 1) { g.SetMargins(17, 20, 17, 20); } else { g.SetMargins(17, 20, 17, 20); } linear.LayoutParameters = g; linear.Orientation = Orientation.Vertical; linear.SetGravity(GravityFlags.Center); linear.Clickable = false; LinearLayout linearLayout = new LinearLayout(this); LinearLayout.LayoutParams m = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WrapContent, LinearLayout.LayoutParams.WrapContent); linearLayout.LayoutParameters = m; if (barrier.State) { linearLayout.SetBackgroundResource(Resource.Drawable.home_icon_on); } else if (!barrier.State) { linearLayout.SetBackgroundResource(Resource.Drawable.home_icon_off); } linearLayout.SetGravity(GravityFlags.Bottom); linearLayout.Orientation = Orientation.Vertical; linearLayout.Id = barrier.Id; linearLayout.SetOnClickListener(this); if (barrier.Id == 0) { linearLayout.SetBackgroundResource(Resource.Drawable.home_icon_on_selected); } TextView textView = new TextView(this); LinearLayout.LayoutParams t = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MatchParent, LinearLayout.LayoutParams.WrapContent); if (Resources.DisplayMetrics.Density == 1) { t.BottomMargin = 10; textView.SetTextSize(Android.Util.ComplexUnitType.Sp, 15); } else { t.BottomMargin = 5; textView.SetTextSize(Android.Util.ComplexUnitType.Sp, 10); } textView.LayoutParameters = t; textView.Text = barrier.Title; textView.SetTextColor(Android.Graphics.Color.White); textView.Gravity = GravityFlags.Center; linearLayout.AddView(textView); LinearLayout ll = new LinearLayout(this); LinearLayout.LayoutParams l = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WrapContent, LinearLayout.LayoutParams.WrapContent); ll.LayoutParameters = l; ll.Orientation = Orientation.Horizontal; ll.SetGravity(GravityFlags.Center); for (int j = 1; j <= 3; j++) { ImageView imageView = new ImageView(this); LinearLayout.LayoutParams imageLayout; if (Resources.DisplayMetrics.Density == 1) { imageLayout = new LinearLayout.LayoutParams(30, 30); } else { imageLayout = new LinearLayout.LayoutParams(30, 30); } imageView.LayoutParameters = imageLayout; if (j <= barrier.Star) { imageView.SetImageResource(Resource.Drawable.game_star_1); } else { imageView.SetImageResource(Resource.Drawable.game_star_2); } if (barrier.Star == 0) { imageView.Visibility = ViewStates.Invisible; } ll.AddView(imageView); } linear.AddView(linearLayout); linear.AddView(ll); glBarriers.AddView(linear); } }
public static View Create (Context context) { GridLayout p = new GridLayout(context); p.UseDefaultMargins = true; p.AlignmentMode = GridAlign.Bounds; Configuration configuration = context.Resources.Configuration; if ((configuration.Orientation == Android.Content.Res.Orientation.Portrait)) { p.ColumnOrderPreserved = false; } else { p.RowOrderPreserved = false; } //FIXME https://bugzilla.xamarin.com/show_bug.cgi?id=14210 GridLayout.Spec titleRow = GridLayout.InvokeSpec (0); GridLayout.Spec introRow = GridLayout.InvokeSpec (1); GridLayout.Spec emailRow = GridLayout.InvokeSpec (2, GridLayout.Baseline); GridLayout.Spec passwordRow = GridLayout.InvokeSpec (3, GridLayout.Baseline); GridLayout.Spec button1Row = GridLayout.InvokeSpec (5); GridLayout.Spec button2Row = GridLayout.InvokeSpec (6); GridLayout.Spec centerInAllColumns = GridLayout.InvokeSpec (0, 4, GridLayout.Center); GridLayout.Spec leftAlignInAllColumns = GridLayout.InvokeSpec (0, 4, GridLayout.Left); GridLayout.Spec labelColumn = GridLayout.InvokeSpec (0, GridLayout.Right); GridLayout.Spec fieldColumn = GridLayout.InvokeSpec (1, GridLayout.Left); GridLayout.Spec defineLastColumn = GridLayout.InvokeSpec (3); GridLayout.Spec fillLastColumn = GridLayout.InvokeSpec (3, GridLayout.Fill); { TextView c = new TextView (context); c.TextSize = 32; c.Text = "Email setup"; p.AddView (c, new GridLayout.LayoutParams (titleRow, centerInAllColumns)); } { TextView c = new TextView (context); c.TextSize = 16; c.Text = "You can configure email in a few simple steps:"; p.AddView (c, new GridLayout.LayoutParams (introRow, leftAlignInAllColumns)); } { TextView c = new TextView (context); c.Text = "Email address:"; p.AddView (c, new GridLayout.LayoutParams (emailRow, labelColumn)); } { EditText c = new EditText (context); c.SetEms (10); c.InputType = Android.Text.InputTypes.ClassText | Android.Text.InputTypes.TextVariationEmailAddress; p.AddView (c, new GridLayout.LayoutParams (emailRow, fieldColumn)); } { TextView c = new TextView (context); c.Text = "Password:"******"Manual setup"; p.AddView (c, new GridLayout.LayoutParams (button1Row, defineLastColumn)); } { Button c = new Button (context); c.Text ="Next"; p.AddView (c, new GridLayout.LayoutParams (button2Row, fillLastColumn)); } return p; }