public Java.Lang.ICharSequence FilterFormatted(Java.Lang.ICharSequence source, int start, int end, global::Android.Text.ISpanned dest, int dstart, int dend) { var s = source.ToString(); var d = dest.ToString(); var proposal = d.Remove(dstart, dend - dstart).Insert(dstart, s.Substring(start, end - start)); if (_onChangeDelegate(proposal)) return null; else { var r = new Java.Lang.String(d.Substring(dstart, dend - dstart)); if (source is ISpanned) { // This spannable thing here, is needed to copy information about which part of // the string is being under composition by the keyboard (or other spans). A // spannable string has support for extra information to the string, besides // its characters and that information must not be lost! var ssb = new SpannableString(r); var spannableEnd = (end <= ssb.Length()) ? end : ssb.Length(); global::Android.Text.TextUtils.CopySpansFrom((ISpanned)source, start, spannableEnd, null, ssb, 0); return ssb; } else return r; } }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); var st = new SpannableString("Test"); st.SetSpan(new TypefaceSpan("Arial"), 0, st.Length(), SpanTypes.ExclusiveExclusive); ActionBar.TitleFormatted = st; }
protected override void OnCreate (Bundle bundle) { base.OnCreate (bundle); var toggle_alarm_operation = new Intent (this, typeof(FindPhoneService)); toggle_alarm_operation.SetAction(FindPhoneService.ACTION_TOGGLE_ALARM); var toggle_alarm_intent = PendingIntent.GetService (this, 0, toggle_alarm_operation, PendingIntentFlags.CancelCurrent); Android.App.Notification.Action alarm_action = new Android.App.Notification.Action (Resource.Drawable.alarm_action_icon, "", toggle_alarm_intent); var cancel_alarm_operation = new Intent (this, typeof(FindPhoneService)); cancel_alarm_operation.SetAction (FindPhoneService.ACTION_CANCEL_ALARM); var cancel_alarm_intent = PendingIntent.GetService (this, 0, cancel_alarm_operation, PendingIntentFlags.CancelCurrent); var title = new SpannableString ("Find My Phone"); title.SetSpan (new RelativeSizeSpan (0.85f), 0, title.Length(), SpanTypes.PointMark); notification = new Notification.Builder (this) .SetContentTitle (title) .SetContentText ("Tap to sound an alarm on phone") .SetSmallIcon (Resource.Drawable.ic_launcher) .SetVibrate (new long[]{ 0, 50 }) .SetDeleteIntent (cancel_alarm_intent) .Extend (new Notification.WearableExtender () .AddAction (alarm_action) .SetContentAction (0) .SetHintHideIcon (true)) .SetLocalOnly (true) .SetPriority ((int)NotificationPriority.Max); ((NotificationManager)GetSystemService (NotificationService)) .Notify (FIND_PHONE_NOTIFICATION_ID, notification.Build ()); Finish (); }
private ISpannable selectBillablePercentageEnabledStateSpan(string percentage, bool isDisabled) { var color = isDisabled ? disabledColor : percentageNormalColor; var spannable = new SpannableString(percentage); spannable.SetSpan(new ForegroundColorSpan(color), 0, spannable.Length(), SpanTypes.ExclusiveExclusive); return(spannable); }
public static void SetIconTypeface(this IMenuItem view, AssetManager asset) { EnsureTypeFace(asset); var mNewTitle = new SpannableString(view.TitleFormatted); mNewTitle.SetSpan(new CustomTypefaceSpan("", iconTypeface), 0, mNewTitle.Length(), SpanTypes.InclusiveInclusive); view.SetTitle(mNewTitle); }
public void SetTitle(string title) { if (title != null) { SpannableString ssbTitle = new SpannableString(title); ssbTitle.SetSpan(mTitleSpan, 0, ssbTitle.Length(), 0); mTitle = ssbTitle; } }
public void SetDetails(string details) { if (details != null) { SpannableString ssbDetail = new SpannableString(details); ssbDetail.SetSpan(mDetailSpan, 0, ssbDetail.Length(), 0); mDetails = ssbDetail; } }
private void DataTemplateBasic(View view, int i, AnimeVideoData animeVideoData) { var str = new SpannableString($"{animeVideoData.Name} - {animeVideoData.AnimeTitle}"); str.SetSpan(PrefixStyle, 0, animeVideoData.Name.Length, SpanTypes.InclusiveInclusive); str.SetSpan(PrefixColorStyle, 0, animeVideoData.Name.Length, SpanTypes.InclusiveInclusive); view.FindViewById <TextView>(Resource.Id.PromoVideosPageItemSubtitle) .SetText(str.SubSequenceFormatted(0, str.Length()), TextView.BufferType.Spannable); }
private void SetTextWithCustomFont(TextView text, String fontName) { if (Text != null) { var s = new SpannableString(Text); s.SetSpan(new TypefaceSpan(text.Context, fontName), 0, s.Length(), SpanTypes.ExclusiveExclusive); text.Text = s.ToString(); } }
public static ICharSequence ToColored(this System.String text, Color color) { ForegroundColorSpan span = new ForegroundColorSpan(color); SpannableString spannable = new SpannableString(text); spannable.SetSpan(span, 0, spannable.Length(), SpanTypes.ExclusiveExclusive); return(spannable); }
private void Rebind() { if (!enabled || DurationTextView == null) { return; } var durationShown = digitsEntered > 0 ? newDuration : oldDuration; var durationText = durationShown.ToString(); var durationSpannable = new SpannableString(durationText); durationSpannable.SetSpan( new ForegroundColorSpan(Color.LightGray), 0, durationSpannable.Length(), SpanTypes.InclusiveExclusive); if (digitsEntered > 0) { // Divider var sepIdx = durationText.IndexOf(":", StringComparison.Ordinal); if (sepIdx >= 0) { durationSpannable.SetSpan( new ForegroundColorSpan(Color.Black), sepIdx, sepIdx + 1, SpanTypes.InclusiveExclusive); } // Color entered minutes durationSpannable.SetSpan( new ForegroundColorSpan(Color.Black), durationText.Length - (Math.Min(digitsEntered, 2)), durationText.Length, SpanTypes.InclusiveExclusive); // Color entered hours if (digitsEntered > 2) { durationSpannable.SetSpan( new ForegroundColorSpan(Color.Black), 2 - (digitsEntered - 2), 2, SpanTypes.InclusiveExclusive); } } DurationTextView.SetText(durationSpannable, TextView.BufferType.Spannable); int num = 0; foreach (var numButton in numButtons) { numButton.Enabled = digitsEntered < 4; num += 1; } DeleteImageButton.Enabled = digitsEntered > 0; Add5Button.Enabled = newDuration.IsValid && newDuration.AddMinutes(5).IsValid; Add30Button.Enabled = newDuration.IsValid && newDuration.AddMinutes(30).IsValid; OkButton.Enabled = digitsEntered > 0 && newDuration.IsValid; }
protected override void OnElementChanged(ElementChangedEventArgs <NavigationPage> e) { base.OnElementChanged(e); var activity = this.Context as Activity; SpannableString s = new SpannableString(activity.ActionBar.Title); s.SetSpan(new TypefaceSpan("Avenir.otf"), 0, s.Length(), SpanTypes.ExclusiveExclusive); activity.ActionBar.TitleFormatted = s; }
private void SetItemBindingsFling(View view, AnimeVideoData animeVideoData) { view.FindViewById(Resource.Id.PromoVideosPageItemImgPlaceholder).Visibility = ViewStates.Visible; view.FindViewById(Resource.Id.PromoVideosPageItemImage).Visibility = ViewStates.Invisible; var str = new SpannableString($"{animeVideoData.Name} - {animeVideoData.AnimeTitle}"); str.SetSpan(PrefixStyle, 0, animeVideoData.Name.Length, SpanTypes.InclusiveInclusive); str.SetSpan(PrefixColorStyle, 0, animeVideoData.Name.Length, SpanTypes.InclusiveInclusive); view.FindViewById <TextView>(Resource.Id.PromoVideosPageItemSubtitle) .SetText(str.SubSequenceFormatted(0, str.Length()), TextView.BufferType.Spannable); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); if (!isOnline()) { mErrorDialog.Show(); return; } SetContentView(Resource.Layout.activity_get_started); mLocationManager = GetSystemService(LocationService) as LocationManager; mTts = new TextToSpeech(this, this, "com.google.android.tts"); speech = SpeechRecognizer.CreateSpeechRecognizer(this); speech.SetRecognitionListener(this); Criteria mLocationServiceCriteria = new Criteria { Accuracy = Accuracy.Coarse, PowerRequirement = Power.Medium }; IList <string> acceptableLocationProviders = mLocationManager.GetProviders(mLocationServiceCriteria, true); if (acceptableLocationProviders.Any()) { mLocationProvider = acceptableLocationProviders.First(); } else { mLocationProvider = string.Empty; } mSharedPreference = GetSharedPreferences(Constants.MY_PREF, 0); token = mSharedPreference.GetString("token", " "); mEditor = mSharedPreference.Edit(); mLoadingDialog = new LoadingDialog(this, Resource.Drawable.main); mLoadingDialog.SetCancelable(false); Window window = mLoadingDialog.Window; window.SetLayout(WindowManagerLayoutParams.MatchParent, WindowManagerLayoutParams.MatchParent); window.SetBackgroundDrawable(new ColorDrawable(Resources.GetColor(Resource.Color.trans))); SpannableString s = new SpannableString("Contoso Cabs"); typeface = Typeface.CreateFromAsset(this.Assets, "JosefinSans-SemiBold.ttf"); s.SetSpan(new TypefaceSpan("Amaranth-Regular.ttf"), 0, s.Length(), SpanTypes.ExclusiveExclusive); s.SetSpan(new ForegroundColorSpan(this.Resources.GetColor(Resource.Color.title)), 0, s.Length(), SpanTypes.ExclusiveExclusive); this.TitleFormatted = s; mGetStarted = FindViewById <Button>(Resource.Id.btnGetStarted); mUri = FindViewById <Button>(Resource.Id.btnuri); mSpeak = FindViewById <ImageView>(Resource.Id.imagespeech); mTextView = FindViewById <TextView>(Resource.Id.bookText); mTextView.SetTypeface(typeface, TypefaceStyle.Normal); mGetStarted.SetTypeface(typeface, TypefaceStyle.Normal); mGetStarted.SetOnClickListener(this); mUri.SetOnClickListener(this); mSpeak.SetOnClickListener(this); }
public void SetTextStyle() { if (Base.TextStyle != TextStyling.None) { SpannableString ss = new SpannableString(Control.Text); ss.SetSpan(new UnderlineSpan(), 0, ss.Length(), SpanTypes.ExclusiveExclusive); Control.TextFormatted = ss; } //TextStyle }
public override void OnCreateOptionsMenu(IMenu menu, MenuInflater inflater) { inflater.Inflate(Resource.Menu.filter_menu, menu); IMenuItem item = menu.FindItem(Resource.Id.filter); SpannableString s = new SpannableString(item.TitleCondensedFormatted); s.SetSpan(new ForegroundColorSpan(Color.ParseColor("#672E8A")), 0, s.Length(), 0); item.SetTitle(s); base.OnCreateOptionsMenu(menu, inflater); }
protected override ISpannable GetFormattedString(string timeString, int lengthOfHours, bool isDisabled) { var color = isDisabled ? disabledColor : normalColor; var spannable = new SpannableString(timeString); var hourSpanEnd = lengthOfHours + 3; spannable.SetSpan(new TypefaceSpan("sans-serif"), 0, hourSpanEnd, SpanTypes.InclusiveInclusive); spannable.SetSpan(new TypefaceSpan("sans-serif-light"), hourSpanEnd, hourSpanEnd + 3, SpanTypes.InclusiveInclusive); spannable.SetSpan(new ForegroundColorSpan(color), 0, spannable.Length(), SpanTypes.InclusiveInclusive); return(spannable); }
private void setUpTvEllipsize5() { var colors = new Color[] { Color.Gray, Color.Magenta, Color.Cyan, Color.Green, Color.Yellow, Color.Red, Color.Blue }; SpannableString longNumberText = new SpannableString(GetString(Resource.String.long_number_text)); for (int i = 0; i < longNumberText.Length(); i += 10) { longNumberText.SetSpan(new ForegroundColorSpan(colors[i / 10 % colors.Length]), i, i + 10, SpanTypes.ExclusiveExclusive); } mTvEllipsize5.SetText(longNumberText, TextView.BufferType.Normal); }
public void AddReadLess(AppCompatTextView textView, ICharSequence text) { try { textView.SetMaxLines(Integer.MaxValue); SpannableStringBuilder spendableStringBuilder = new SpannableStringBuilder(text); spendableStringBuilder.Append(" "); spendableStringBuilder.Append(LessLabel); SpannableString ss = SpannableString.ValueOf(spendableStringBuilder); ClickableSpan rclickableSpan = new StRclickableSpan(this, textView, text, StTools.StTypeText.ReadLess); ss.SetSpan(rclickableSpan, ss.Length() - LessLabel.Length, ss.Length(), SpanTypes.ExclusiveExclusive); // textView.SetTextFuture(PrecomputedTextCompat.GetTextFuture(ss, TextViewCompat.GetTextMetricsParams(textView), null)); textView.SetText(ss, TextView.BufferType.Spannable); textView.MovementMethod = (LinkMovementMethod.Instance); } catch (Exception e) { Console.WriteLine(e); } }
public void SetAppearance(BottomNavigationView bottomView, IShellAppearanceElement appearance) { IMenu myMenu = bottomView.Menu; for (int i = 0; i < myMenu.Size(); i++) { var item = myMenu.GetItem(i); SpannableString span = new SpannableString(item.ToString()); int end = span.Length(); //span.SetSpan(new AbsoluteSizeSpan(14, true), 0, end, SpanTypes.ExclusiveExclusive); span.SetSpan(new Rel ativeSizeSpan(0.8f), 0, end, SpanTypes.ExclusiveExclusive); item.SetTitle(span); } }
public override bool OnPrepareOptionsMenu(IMenu menu) { // Change text color in menu IMenuItem item = menu.FindItem(Resource.Id.close_session); SpannableString s = new SpannableString(item.TitleCondensedFormatted); s.SetSpan(new ForegroundColorSpan(Color.ParseColor("#672E8A")), 0, s.Length(), 0); item.SetTitle(s); bool result = base.OnPrepareOptionsMenu(menu); return(result); }
private void SetActionbarFont() { try { //CalligraphyConfig.initDefault(new CalligraphyConfig.Builder() // .setDefaultFontPath(Joyces.Helpers.Settings.MainFont) // .build()); // "fonts/Roboto-RobotoRegular.ttf" try { Typeface tf = Typeface.CreateFromAsset(Assets, Joyces.Helpers.Settings.MainFont); SpannableString st = new SpannableString(Lang.APPLICATION_NAME); //st.SetSpan(new TypefaceSpan(this, "Signika-Regular.otf"), 0, st.Length(), SpanTypes.ExclusiveExclusive); //string errorMessage = "God kväll"; //SpannableString wordtoSpan = new SpannableString(); //wordtoSpan.SetSpan(new ForegroundColorSpan(new Color(255, 124, 67, 149)), 34, errorMessage.Length, SpanTypes.ExclusiveExclusive); st.SetSpan(tf, 0, st.Length(), SpanTypes.ExclusiveExclusive); ActionBar.TitleFormatted = st; } catch (Exception ee) { } //ActionBar actionBar = ActionBar; //TextView TextViewNewFont = new TextView(this); //ViewGroup.LayoutParams layoutparams = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.WrapContent); //TextViewNewFont.LayoutParameters = layoutparams; //TextViewNewFont.Text = "Actionbar Title"; //TextViewNewFont.SetTextColor(Color.Red); //TextViewNewFont.Gravity = GravityFlags.Center; //TextViewNewFont.SetTextSize(Android.Util.ComplexUnitType.Sp, 27); //ExternalFontPath = "Montserrat-Regulart.ttf"; //FontLoaderTypeface = Typeface.CreateFromAsset(Assets, Joyces.Helpers.Settings.MainFont); //Typeface.CreateFromAsset(Assets, ExternalFontPath); //TextViewNewFont.SetTypeface(FontLoaderTypeface, TypefaceStyle.Normal); //// actionBar.SetCustomView(TextViewNewFont); //ActionBar.SetCustomView(TextViewNewFont, new Android.App.ActionBar.LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent)); } catch (Exception e) { } }
private ISpannable selectTimeSpanEnabledStateSpan(string timeString, int emphasizedPartLength, bool isDisabled) { var color = isDisabled ? disabledColor : timeSpanNormalColor; var spannable = new SpannableString(timeString); spannable.SetSpan(new TypefaceSpan("sans-serif"), 0, emphasizedPartLength, SpanTypes.InclusiveInclusive); if (emphasizedPartLength < timeString.Length) { spannable.SetSpan(new TypefaceSpan("sans-serif-light"), emphasizedPartLength, timeString.Length, SpanTypes.InclusiveInclusive); } spannable.SetSpan(new ForegroundColorSpan(color), 0, spannable.Length(), SpanTypes.InclusiveInclusive); return(spannable); }
protected override void OnTitleChanged(Java.Lang.ICharSequence title, Android.Graphics.Color color) { //base.OnTitleChanged (title, color); this.SupportActionBar.Title = title.ToString(); SpannableString s = new SpannableString(title); CustomTypefaceSpan newSpan = new CustomTypefaceSpan(this, "Orbitron-Regular.ttf"); s.SetSpan(newSpan, 0, s.Length(), SpanTypes.ExclusiveExclusive); s.SetSpan(new ForegroundColorSpan(Resources.GetColor(Resource.Color.Phabrik_black)), 0, s.Length(), SpanTypes.ExclusiveExclusive); this.SupportActionBar.TitleFormatted = s; }
public void Run() { try { int textLengthNew = Option.TextLength; if (Option.TextLengthType == TypeLine) { if (TextView.Layout.LineCount <= Option.TextLength) { TextView.SetText(Text, TextView.BufferType.Spannable); return; } ViewGroup.MarginLayoutParams lp = (ViewGroup.MarginLayoutParams)TextView.LayoutParameters; string subString = Text.ToString().Substring(TextView.Layout.GetLineStart(0), TextView.Layout.GetLineEnd(Option.TextLength - 1)); textLengthNew = subString.Length - (Option.MoreLabel.Length + 4 + lp.RightMargin / 6); } SpannableStringBuilder spendableStringBuilder = new SpannableStringBuilder(Text.SubSequence(0, textLengthNew)); spendableStringBuilder.Append(" ..."); spendableStringBuilder.Append(Option.MoreLabel); SpannableString ss = SpannableString.ValueOf(spendableStringBuilder); ClickableSpan rclickableSpan = new StRclickableSpan(Option, TextView, Text, StTools.StTypeText.ReadMore); ss.SetSpan(rclickableSpan, ss.Length() - Option.MoreLabel.Length, ss.Length(), SpanTypes.ExclusiveExclusive); switch (Build.VERSION.SdkInt) { case >= BuildVersionCodes.JellyBean when Option.ExpandAnimation: { LayoutTransition layoutTransition = new LayoutTransition(); layoutTransition.EnableTransitionType(LayoutTransitionType.Changing); ((ViewGroup)TextView?.Parent).LayoutTransition = layoutTransition; break; } } //TextView.SetTextFuture(PrecomputedTextCompat.GetTextFuture(ss, TextViewCompat.GetTextMetricsParams(TextView), null)); TextView.SetText(ss, TextView.BufferType.Spannable); TextView.MovementMethod = LinkMovementMethod.Instance; } catch (Exception e) { Methods.DisplayReportResultTrack(e); } }
void formatearTextos() { btnReLLamada.Typeface = fontRegular; SpannableString contenido = new SpannableString(TEXTO_NO_RECIBI_SMS); contenido.SetSpan(new UnderlineSpan(), 0, contenido.Length(), 0); btnReLLamada.TextFormatted = contenido; SpannableString spanString = new SpannableString(TEXTO_NO_TITULO_SMS); spanString.SetSpan(new CustomTypefaceSpan(fontRegular), 0, 5, SpanTypes.ExclusiveExclusive); spanString.SetSpan(new CustomTypefaceSpan(fontSemiBold), 6, 27, SpanTypes.ExclusiveExclusive); spanString.SetSpan(new CustomTypefaceSpan(fontRegular), 27, spanString.Length(), SpanTypes.ExclusiveExclusive); txtInstruccionAutenticacion.TextFormatted = spanString; }
private void AssertNoSpansOutsideSpecifiedIntervalApplied <T>(SpannableString?spannable, TextRange textRange) { int spannableLength = spannable?.Length() ?? 0; if (textRange.Position > 0) { var spansBefore = GetSpans <T>(spannable, new TextRange(0, textRange.Position - 1)); Assert.Empty(spansBefore); } if (textRange.Position + textRange.Length < spannableLength - 1) { var spansAfter = GetSpans <T>(spannable, new TextRange(textRange.Position + textRange.Length + 1, spannableLength - 1)); Assert.Empty(spansAfter); } }
private void AddTextToView(TextView textView, string title, string text) { AndroidApplication.Logger.Debug(() => $"OpenSourceLicensesActivity:AddTextBlock {title}"); var textTitle = new SpannableString(title); var titleLength = textTitle.Length(); textTitle.SetSpan(new UnderlineSpan(), 0, titleLength, 0); textTitle.SetSpan(new StyleSpan(TypefaceStyle.Bold), 0, titleLength, 0); textView.Append(textTitle); textView.Append("\n\n"); textView.Append(text); textView.Append("\n\n"); }
private void UpdateKeySummary(string providerAPI) { if (!String.IsNullOrWhiteSpace(Settings.API_KEY)) { var keyVerified = Settings.KeyVerified; ForegroundColorSpan colorSpan = new ForegroundColorSpan(keyVerified ? Color.Green : Color.Red); ISpannable summary = new SpannableString(keyVerified ? GetString(Resource.String.message_keyverified) : GetString(Resource.String.message_keyinvalid)); summary.SetSpan(colorSpan, 0, summary.Length(), 0); keyEntry.SummaryFormatted = summary; } else { keyEntry.Summary = Activity.GetString(Resource.String.pref_summary_apikey, providerAPI); } }
//Color menu items private void colorMenu() { IMenuItem menuItem = navview.Menu.FindItem(Resource.Id.navCall); SpannableString s = new SpannableString(menuItem.TitleFormatted); s.SetSpan(new ForegroundColorSpan(Color.DarkOrange), 0, s.Length(), 0); menuItem.SetTitle(s); menuItem = navview.Menu.FindItem(Resource.Id.navLocation); s = new SpannableString(menuItem.TitleFormatted); s.SetSpan(new ForegroundColorSpan(Color.DarkOrange), 0, s.Length(), 0); menuItem.SetTitle(s); menuItem = navview.Menu.FindItem(Resource.Id.navLogout); s = new SpannableString(menuItem.TitleFormatted); s.SetSpan(new ForegroundColorSpan(Color.Red), 0, s.Length(), 0); menuItem.SetTitle(s); }
private void init(View view) { if (!isOnline()) { mErrorDialog.Show(); } else { SpannableString s = new SpannableString("Feedback"); typeface = Typeface.CreateFromAsset(navigationActivity.Assets, "JosefinSans-SemiBold.ttf"); s.SetSpan(new TypefaceSpan("Amaranth-Regular.ttf"), 0, s.Length(), SpanTypes.ExclusiveExclusive); s.SetSpan(new ForegroundColorSpan(navigationActivity.Resources.GetColor(Resource.Color.title)), 0, s.Length(), SpanTypes.ExclusiveExclusive); navigationActivity.TitleFormatted = s; Intent emailIntent = new Intent(Intent.ActionSendto, Android.Net.Uri.FromParts("mailto", "*****@*****.**", null)); emailIntent.PutExtra(Intent.ExtraSubject, "Feedback from User"); StartActivity(Intent.CreateChooser(emailIntent, "Send Feedback...")); } }
private void SetItemBindingsFull(View view, AnimeVideoData animeVideoData) { var img = view.FindViewById <ImageViewAsync>(Resource.Id.PromoVideosPageItemImage); if ((string)img.Tag != animeVideoData.YtLink) { view.FindViewById(Resource.Id.PromoVideosPageItemImgPlaceholder).Visibility = ViewStates.Gone; img.Tag = animeVideoData.YtLink; img.Into(animeVideoData.Thumb); } var str = new SpannableString($"{animeVideoData.Name} - {animeVideoData.AnimeTitle}"); str.SetSpan(PrefixStyle, 0, animeVideoData.Name.Length, SpanTypes.InclusiveInclusive); str.SetSpan(PrefixColorStyle, 0, animeVideoData.Name.Length, SpanTypes.InclusiveInclusive); view.FindViewById <TextView>(Resource.Id.PromoVideosPageItemSubtitle) .SetText(str.SubSequenceFormatted(0, str.Length()), TextView.BufferType.Spannable); }
private void setUpTvEllipsize4() { string timeText = " 1 minute ago"; SpannableString timeLongText = new SpannableString(GetString(Resource.String.long_text) + timeText); timeLongText.SetSpan(new TextAppearanceSpan(this, Resource.Style.time_style), timeLongText.Length() - timeText.Length, timeLongText.Length(), SpanTypes.ExclusiveExclusive); SpannableString moreText = new SpannableString("...more"); moreText.SetSpan(new EllipsizeSpan(mTvEllipsize4, timeLongText), 3, moreText.Length(), SpanTypes.ExclusiveExclusive); moreText.SetSpan(new TextAppearanceSpan(this, Resource.Style.link_style), 3, moreText.Length(), SpanTypes.ExclusiveExclusive); mTvEllipsize4.MovementMethod = LinkMovementMethod.Instance; mTvEllipsize4.SetText(timeLongText, TextView.BufferType.Normal); mTvEllipsize4.SetEllipsizeText(moreText, timeText.Length); }
public static void SetTextWithRouble(this TextView label, string text, RoubleType roubleType) { var textFormatted = new SpannableString(text + Roubles.GetRoubleSymbFor(roubleType)); textFormatted.SetSpan(RoubleSpan, textFormatted.Length() - 1, textFormatted.Length(), SpanTypes.ExclusiveExclusive); label.TextFormatted = textFormatted; }
public void FillImagePost(PostImageViewHolder vh,int position){ try{ vh.AuthorName.Text = _Posts[position].AuthorName; var context = Android.App.Application.Context; vh.HeaderRating.Text = _Posts [position].Rating.ToString (); vh.BottomRating.Text = _Posts [position].Rating.ToString (); if (_Posts [position].Rating > 0) { vh.HeaderRating.SetTextColor (context.Resources.GetColor(Resource.Color.mainGreen)); vh.BottomRating.SetTextColor (context.Resources.GetColor(Resource.Color.mainGreen)); var text = " + "+_Posts[position].Rating; vh.HeaderRating.Text = text; vh.BottomRating.Text = text; } if (_Posts [position].Rating < 0) { vh.HeaderRating.SetTextColor (context.Resources.GetColor(Resource.Color.red)); vh.BottomRating.SetTextColor (context.Resources.GetColor(Resource.Color.red)); var text = ""+_Posts[position].Rating; vh.HeaderRating.Text = text; vh.BottomRating.Text = text; } vh.PostTime.Text = _Posts[position].PostTime; vh.Title.Text = _Posts[position].Title; if(_Posts[position].Description!=null && !String.IsNullOrEmpty(_Posts[position].Description.ToString())){ vh.Description.Text = _Posts[position].Description.ToString(); vh.Description.Visibility = ViewStates.Visible; }else{ vh.Description.Text = String.Empty; vh.Description.Visibility = ViewStates.Gone; } // if(_Posts[position].FormattedDescription!=null && _Posts[position].FormattedDescription.Count>0){ // SpannableStringBuilder descriptionBulder = new SpannableStringBuilder(); // Color descTextColorDarkGray = context.Resources.GetColor(Resource.Color.darkGray); // Color descTextColorGray = context.Resources.GetColor(Resource.Color.gray); // // foreach(var des in _Posts[position].FormattedDescription){ // if(des.Item1 == "text"){ // SpannableString tag1 = new SpannableString(des.Item2); // // tag1.SetSpan(new ForegroundColorSpan(descTextColorGray), 0, tag1.Length(), SpanTypes.ExclusiveExclusive); // descriptionBulder.Append(tag1); // } // if(des.Item1 == "textLink"){ // SpannableString tag2 = new SpannableString(des.Item2); // // tag2.SetSpan(new ForegroundColorSpan(descTextColorDarkGray), 0, tag2.Length(), SpanTypes.ExclusiveExclusive); // descriptionBulder.Append(tag2); // } // } // if(descriptionBulder.Count()>0){ // //vh.Description.TextFormatted = descriptionBulder; // vh.Description.SetText(descriptionBulder,TextView.BufferType.Spannable); // } // }else{ // vh.Description.Visibility = ViewStates.Invisible; // vh.Description.Text = null; // } //vh._Description.Text = _Posts[position].Description; //vh._Description.Text = _Posts[position].Description; SpannableStringBuilder stringBuilder = new SpannableStringBuilder(); Color textColor = context.Resources.GetColor(Resource.Color.mainGreen); var tagsBuilder = new StringBuilder(); foreach (var tag in _Posts[position].Tags) { SpannableString tag1 = new SpannableString("#"+tag); tag1.SetSpan(new ForegroundColorSpan(textColor), 0, tag1.Length(), SpanTypes.ExclusiveInclusive); stringBuilder.Append(tag1); stringBuilder.Append(" "); //SpannableString tag2 = new SpannableString(" "); //stringBuilder.Append(tag2); //stringBuilder.SetSpan(new TagSpan(backgroundColor, backgroundColor), stringBuilder.Length() - tag2.Length(), stringBuilder.Length(), SpanTypes.ExclusiveExclusive); //tagsBuilder.Append("#"+tag+" "); } vh.Tags.SetText(stringBuilder,TextView.BufferType.Spannable); //vh.Tags.Text = tagsBuilder.ToString(); //vh.Tags.TextFormatted = stringBuilder; vh.Comments.Text = _Posts[position].Comments.ToString(); vh.Image.Click -= videoHandler; vh.Image.Click -= imageHandler; vh.Image.Click -= gifHandler; if(_Posts[position].PostType==PostType.Video){ if (vh.Image != null) { vh.Image.SetTag (Resource.String.currentPosition, vh.AdapterPosition.ToString ()); vh.Image.SetTag (Resource.String.imageUrl, _Posts [vh.AdapterPosition].VideoUrl); vh.Image.Click -= imageHandler; vh.Image.Click -= gifHandler; vh.Image.Click -= videoHandler; vh.Image.Click += videoHandler; Picasso.With(Android.App.Application.Context) .Load(_Posts[position].Url) .Transform(new CropSquareTransformation()) .Into(vh.Image); } } if(_Posts[position].PostType==PostType.Image){ if (vh.Image != null) { vh.Image.SetTag (Resource.String.currentPosition, vh.AdapterPosition.ToString ()); vh.Image.SetTag (Resource.String.imageUrl, _Posts [vh.AdapterPosition].Url); vh.Image.SetTag (Resource.String.isbiggeravailable,_Posts [vh.AdapterPosition].IsBiggerAvailable); vh.Image.Click -= videoHandler; vh.Image.Click -= gifHandler; vh.Image.Click -= imageHandler; vh.Image.Click += imageHandler; Picasso.With(Android.App.Application.Context) .Load(_Posts[position].Url) .Transform(new CropSquareTransformation()) .Into(vh.Image); } } if(_Posts[position].PostType==PostType.Gif){ if (vh.Image != null) { vh.Image.SetTag (Resource.String.currentPosition, vh.AdapterPosition.ToString ()); vh.Image.SetTag (Resource.String.imageUrl, _Posts [vh.AdapterPosition].GifUrl); vh.Image.Click -= videoHandler; vh.Image.Click -= imageHandler; vh.Image.Click -= gifHandler; vh.Image.Click += gifHandler; Picasso.With(Android.App.Application.Context) .Load(_Posts[position].Url) .Transform(new CropSquareTransformation()) .Into(vh.Image); } } }catch(Exception ex){ Insights.Initialize("0637c26a1b2e27693e05298f7c3c3a04c102a3c7", Application.Context); Insights.Report(ex,new Dictionary<string,string>{{"Message",ex.Message}},Insights.Severity.Error); var text = ex.Message; } }
public void FillMultiImagePost(PostMultiImageViewHolder vh, int position) { try { vh.AuthorName.Text = _Posts[position].AuthorName; var context = Android.App.Application.Context; vh.HeaderRating.Text = _Posts[position].Rating.ToString(); vh.BottomRating.Text = _Posts[position].Rating.ToString(); if (_Posts[position].Rating > 0) { vh.HeaderRating.SetTextColor(context.Resources.GetColor(Resource.Color.mainGreen)); vh.BottomRating.SetTextColor(context.Resources.GetColor(Resource.Color.mainGreen)); var text = " + " + _Posts[position].Rating; vh.HeaderRating.Text = text; vh.BottomRating.Text = text; } if (_Posts[position].Rating < 0) { vh.HeaderRating.SetTextColor(context.Resources.GetColor(Resource.Color.red)); vh.BottomRating.SetTextColor(context.Resources.GetColor(Resource.Color.red)); var text = "" + _Posts[position].Rating; vh.HeaderRating.Text = text; vh.BottomRating.Text = text; } vh.PostTime.Text = _Posts[position].PostTime; vh.Title.Text = _Posts[position].Title; if (_Posts[position].Description != null && !String.IsNullOrEmpty(_Posts[position].Description.ToString())) { vh.Description.Text = _Posts[position].Description.ToString(); vh.Description.Visibility = ViewStates.Visible; } else { vh.Description.Text = String.Empty; vh.Description.Visibility = ViewStates.Gone; } SpannableStringBuilder stringBuilder = new SpannableStringBuilder(); Color textColor = context.Resources.GetColor(Resource.Color.mainGreen); foreach (var tag in _Posts[position].Tags) { SpannableString tag1 = new SpannableString("#" + tag); tag1.SetSpan(new ForegroundColorSpan(textColor), 0, tag1.Length(), SpanTypes.ExclusiveExclusive); stringBuilder.Append(tag1); stringBuilder.Append(" "); //SpannableString tag2 = new SpannableString(" "); //stringBuilder.Append(tag2); //stringBuilder.SetSpan(new TagSpan(backgroundColor, backgroundColor), stringBuilder.Length() - tag2.Length(), stringBuilder.Length(), SpanTypes.ExclusiveExclusive); } vh.Tags.SetText(stringBuilder, TextView.BufferType.Spannable); vh.Comments.Text = _Posts[position].Comments.ToString(); ImageAdapter adapter = new ImageAdapter(context, _Posts[position].Images); vh.Rotator.Adapter = adapter; } catch (Exception ex) { Insights.Initialize("0637c26a1b2e27693e05298f7c3c3a04c102a3c7", Application.Context); Insights.Report(ex, new Dictionary<string, string> { { "Message", ex.Message } }, Insights.Severity.Error); var text = ex.Message; } }
SpannableString generateCenterSpannableText() { SpannableString s = new SpannableString("MPAndroidChart developed by Philipp Jahoda"); s.SetSpan(new RelativeSizeSpan(1.7f), 0, 14, 0); s.SetSpan(new StyleSpan(TypefaceStyle.Normal), 14, s.Length() - 15, 0); s.SetSpan(new ForegroundColorSpan(Color.Gray), 14, s.Length() - 15, 0); s.SetSpan(new RelativeSizeSpan(.8f), 14, s.Length() - 15, 0); s.SetSpan(new StyleSpan(TypefaceStyle.Italic), s.Length() - 14, s.Length(), 0); s.SetSpan(new ForegroundColorSpan(ColorTemplate.HoloBlue), s.Length() - 14, s.Length(), 0); return s; }
private void Render (Marker marker, View view) { int badge; // Use the equals() method on a Marker to check for equals. Do not use ==. if (marker.Equals(parent.mBrisbane)) { badge = Resource.Drawable.badge_qld; } else if (marker.Equals(parent.mAdelaide)) { badge = Resource.Drawable.badge_sa; } else if (marker.Equals(parent.mSydney)) { badge = Resource.Drawable.badge_nsw; } else if (marker.Equals(parent.mMelbourne)) { badge = Resource.Drawable.badge_victoria; } else if (marker.Equals(parent.mPerth)) { badge = Resource.Drawable.badge_wa; } else { // Passing 0 to setImageResource will clear the image view. badge = 0; } ((ImageView) view.FindViewById (Resource.Id.badge)).SetImageResource (badge); String title = marker.Title; TextView titleUi = ((TextView) view.FindViewById (Resource.Id.title)); if (title != null) { // Spannable string allows us to edit the formatting of the text. SpannableString titleText = new SpannableString (title); SpanTypes st = (SpanTypes) 0; titleText.SetSpan (new ForegroundColorSpan (Color.Red), 0, titleText.Length (), st); titleUi.TextFormatted = (titleText); } else { titleUi.Text = (""); } String snippet = marker.Snippet; TextView snippetUi = ((TextView) view.FindViewById(Resource.Id.snippet)); if (snippet != null) { SpannableString snippetText = new SpannableString(snippet); snippetText.SetSpan(new ForegroundColorSpan(Color.Magenta), 0, 10, 0); snippetText.SetSpan(new ForegroundColorSpan(Color.Blue), 12, 21, 0); snippetUi.TextFormatted = (snippetText); } else { snippetUi.Text = (""); } }
private void Rebind () { if (!enabled || DurationTextView == null) return; var durationShown = digitsEntered > 0 ? newDuration : oldDuration; var durationText = durationShown.ToString (); var durationSpannable = new SpannableString (durationText); durationSpannable.SetSpan ( new ForegroundColorSpan (Color.LightGray), 0, durationSpannable.Length (), SpanTypes.InclusiveExclusive); if (digitsEntered > 0) { // Divider var sepIdx = durationText.IndexOf (":", StringComparison.Ordinal); if (sepIdx >= 0) { durationSpannable.SetSpan ( new ForegroundColorSpan (Color.Black), sepIdx, sepIdx + 1, SpanTypes.InclusiveExclusive); } // Color entered minutes durationSpannable.SetSpan ( new ForegroundColorSpan (Color.Black), durationText.Length - (Math.Min (digitsEntered, 2)), durationText.Length, SpanTypes.InclusiveExclusive); // Color entered hours if (digitsEntered > 2) { durationSpannable.SetSpan ( new ForegroundColorSpan (Color.Black), 2 - (digitsEntered - 2), 2, SpanTypes.InclusiveExclusive); } } DurationTextView.SetText (durationSpannable, TextView.BufferType.Spannable); int num = 0; foreach (var numButton in numButtons) { numButton.Enabled = digitsEntered < 4; num += 1; } DeleteImageButton.Enabled = digitsEntered > 0; Add5Button.Enabled = newDuration.IsValid && newDuration.AddMinutes (5).IsValid; Add30Button.Enabled = newDuration.IsValid && newDuration.AddMinutes (30).IsValid; OkButton.Enabled = digitsEntered > 0 && newDuration.IsValid; }