private List <Color> GetCustomColorsList(ObservableCollection <ChartDataModel> ocdm) { List <Color> colors = new List <Color>(); foreach (ChartDataModel cdm in ocdm) { colors.Add(CryptoCoinColors.GetCryptoCoinColor(cdm.Name)); } return(colors); }
private CardView CreateCardViewScheme3(string symbol, string description, string numberOfCoinsText, string valueText, string priceText, Color chgColor, string chgText, string timeText) { CardView cardView = new CardView(Context); int cardViewWidth; cardViewWidth = (GetScreenWidthInPixels() - DpToPixels(6)) / 2; GridLayout.LayoutParams gridLayoutParams = new GridLayout.LayoutParams(); gridLayoutParams.Width = cardViewWidth; gridLayoutParams.Height = DpToPixels(144); gridLayoutParams.LeftMargin = DpToPixels(2); gridLayoutParams.RightMargin = DpToPixels(2); gridLayoutParams.TopMargin = DpToPixels(2); RelativeLayout rl = new RelativeLayout(cardView.Context); cardView.Tag = new Identifier(symbol); cardView.AddView(rl); Button topColorStripe = new Button(cardView.Context); topColorStripe.SetBackgroundColor(CryptoCoinColors.GetCryptoCoinColor(symbol)); RelativeLayout.LayoutParams lpbb = CreateRelativeLayoutParams(); lpbb.Width = ViewGroup.LayoutParams.MatchParent; lpbb.Height = DpToPixels(6); topColorStripe.LayoutParameters = lpbb; topColorStripe.Id = 1; rl.AddView(topColorStripe); TextView symTV = CreateTextViewEx(symbol, Color.Black, 30, TypefaceStyle.Bold, cardView.Context); RelativeLayout.LayoutParams lps = CreateRelativeLayoutParams(); lps.AddRule(LayoutRules.Below, topColorStripe.Id); symTV.LayoutParameters = lps; symTV.Id = 2; rl.AddView(symTV); TextView descTV = CreateTextViewEx(description, Color.Gray, 12, TypefaceStyle.Normal, cardView.Context); RelativeLayout.LayoutParams lpd = CreateRelativeLayoutParams(); lpd.AddRule(LayoutRules.RightOf, symTV.Id); lpd.LeftMargin = DpToPixels(2); lpd.TopMargin = DpToPixels(20); descTV.LayoutParameters = lpd; descTV.Id = 3; rl.AddView(descTV); TextView coinsLabelTV = CreateTextViewEx("Coins", Color.Gray, 10, TypefaceStyle.Normal, cardView.Context); RelativeLayout.LayoutParams lpnc = CreateRelativeLayoutParams(); lpnc.AddRule(LayoutRules.Below, symTV.Id); lpnc.LeftMargin = DpToPixels(2); lpnc.TopMargin = DpToPixels(2); coinsLabelTV.LayoutParameters = lpnc; coinsLabelTV.Id = 4; rl.AddView(coinsLabelTV); TextView coinsTV = CreateTextViewEx(numberOfCoinsText, Color.Black, 12, TypefaceStyle.Normal, cardView.Context); RelativeLayout.LayoutParams lpcv = CreateRelativeLayoutParams(); lpcv.AddRule(LayoutRules.RightOf, coinsLabelTV.Id); lpcv.AddRule(LayoutRules.AlignTop, coinsLabelTV.Id); lpcv.LeftMargin = DpToPixels(5); coinsTV.LayoutParameters = lpcv; coinsTV.Id = 5; rl.AddView(coinsTV); TextView valueLabelTV = CreateTextViewEx("Value", Color.Gray, 10, TypefaceStyle.Normal, cardView.Context); RelativeLayout.LayoutParams lpvl = CreateRelativeLayoutParams(); lpvl.AddRule(LayoutRules.Below, coinsTV.Id); lpvl.LeftMargin = DpToPixels(2); lpvl.TopMargin = DpToPixels(2); valueLabelTV.LayoutParameters = lpvl; valueLabelTV.Id = 6; rl.AddView(valueLabelTV); TextView valueTV = CreateTextViewEx(valueText, Color.ParseColor("#EFCC00"), 16, TypefaceStyle.Bold, cardView.Context); RelativeLayout.LayoutParams lpv = CreateRelativeLayoutParams(); lpv.AddRule(LayoutRules.RightOf, valueLabelTV.Id); lpv.AddRule(LayoutRules.AlignTop, valueLabelTV.Id); lpv.LeftMargin = DpToPixels(2); valueTV.LayoutParameters = lpv; valueTV.Id = 7; rl.AddView(valueTV); TextView priceLabelTV = CreateTextViewEx("Price", Color.Gray, 10, TypefaceStyle.Normal, cardView.Context); RelativeLayout.LayoutParams lpvp = CreateRelativeLayoutParams(); lpvp.AddRule(LayoutRules.Below, valueTV.Id); lpvp.LeftMargin = DpToPixels(2); lpvp.TopMargin = DpToPixels(2); priceLabelTV.LayoutParameters = lpvp; priceLabelTV.Id = 8; rl.AddView(priceLabelTV); TextView priceTV = CreateTextViewEx(priceText, chgColor, 14, TypefaceStyle.Bold, cardView.Context); RelativeLayout.LayoutParams lpp = CreateRelativeLayoutParams(); lpp.AddRule(LayoutRules.RightOf, priceLabelTV.Id); lpp.AddRule(LayoutRules.AlignTop, priceLabelTV.Id); lpp.LeftMargin = DpToPixels(2); lpp.TopMargin = DpToPixels(2); priceTV.LayoutParameters = lpp; priceTV.Id = 9; rl.AddView(priceTV); TextView chgTV = CreateTextViewEx(chgText, chgColor, 12, TypefaceStyle.Normal, cardView.Context); RelativeLayout.LayoutParams lpc = CreateRelativeLayoutParams(); lpc.AddRule(LayoutRules.Below, priceTV.Id); lpc.TopMargin = DpToPixels(2); chgTV.LayoutParameters = lpc; chgTV.Id = 10; rl.AddView(chgTV); TextView timeTV = CreateTextViewEx(timeText, Color.Gray, 8, TypefaceStyle.Normal, cardView.Context); RelativeLayout.LayoutParams lpt = CreateRelativeLayoutParams(); lpt.AddRule(LayoutRules.Below, chgTV.Id); lpt.AddRule(LayoutRules.AlignLeft, chgTV.Id); timeTV.LayoutParameters = lpt; timeTV.Id = 11; rl.AddView(timeTV); cardView.LayoutParameters = gridLayoutParams; return(cardView); }