コード例 #1
0
            public bool OnActionItemClicked(ActionMode mode, IMenuItem item)
            {
                CharacterStyle         cs;
                int                    start = edt.SelectionStart;
                int                    end   = edt.SelectionEnd;
                SpannableStringBuilder ssb   = new SpannableStringBuilder(edt.Text);

                switch (item.ItemId)
                {
                case Resource.Id.bold:
                    cs = new StyleSpan(TypefaceStyle.Bold);
                    ssb.SetSpan(cs, start, end, SpanTypes.ExclusiveExclusive);
                    edt.Text = ssb.ToString();
                    return(true);

                case Resource.Id.italic:
                    cs = new StyleSpan(TypefaceStyle.Italic);
                    ssb.SetSpan(cs, start, end, SpanTypes.ExclusiveExclusive);
                    edt.Text = ssb.ToString();
                    return(true);

                case Resource.Id.underline:
                    cs = new UnderlineSpan();
                    ssb.SetSpan(cs, start, end, SpanTypes.ExclusiveExclusive);
                    edt.Text = ssb.ToString();
                    return(true);

                case Resource.Id.strikethrough:
                    cs = new StrikethroughSpan();
                    ssb.SetSpan(cs, start, end, SpanTypes.ExclusiveExclusive);
                    edt.Text = ssb.ToString();
                    return(true);
                }
                return(false);
            }
コード例 #2
0
        private HtmlObject getStyledObject(StyleSpan span, string content, int start, int end, float thisXOffset)
        {
            TextPaint paint = PaintFromHeap;
                    paint.SetTypeface(Typeface.DefaultFromStyle(span.Style));
                    paint.TextSize = mTextsize;
                    paint.Color = mColor;

                    span.UpdateDrawState(paint);
                    span.UpdateMeasureState(paint);
                    HtmlObject obj = new HtmlObject(this, content, start, end, thisXOffset, paint);
                    obj.recycle = true;
                    return obj;
        }