当前位置: 首页>>代码示例>>Java>>正文


Java SuperscriptSpan类代码示例

本文整理汇总了Java中android.text.style.SuperscriptSpan的典型用法代码示例。如果您正苦于以下问题:Java SuperscriptSpan类的具体用法?Java SuperscriptSpan怎么用?Java SuperscriptSpan使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


SuperscriptSpan类属于android.text.style包,在下文中一共展示了SuperscriptSpan类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setPenAttr

import android.text.style.SuperscriptSpan; //导入依赖的package包/类
public void setPenAttr(CaptionPenAttr penAttr) {
    mCharacterStyles.clear();
    if (penAttr.italic) {
        mCharacterStyles.add(new StyleSpan(Typeface.ITALIC));
    }
    if (penAttr.underline) {
        mCharacterStyles.add(new UnderlineSpan());
    }
    switch (penAttr.penSize) {
        case CaptionPenAttr.PEN_SIZE_SMALL:
            mCharacterStyles.add(new RelativeSizeSpan(PROPORTION_PEN_SIZE_SMALL));
            break;
        case CaptionPenAttr.PEN_SIZE_LARGE:
            mCharacterStyles.add(new RelativeSizeSpan(PROPORTION_PEN_SIZE_LARGE));
            break;
    }
    switch (penAttr.penOffset) {
        case CaptionPenAttr.OFFSET_SUBSCRIPT:
            mCharacterStyles.add(new SubscriptSpan());
            break;
        case CaptionPenAttr.OFFSET_SUPERSCRIPT:
            mCharacterStyles.add(new SuperscriptSpan());
            break;
    }
}
 
开发者ID:trevd,项目名称:android_packages_apps_tv,代码行数:26,代码来源:CaptionWindowLayout.java

示例2: onCreate

import android.text.style.SuperscriptSpan; //导入依赖的package包/类
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.ac_main);

    Spanned spanned = null;

    if(Build.VERSION.SDK_INT < Build.VERSION_CODES.N) {
        spanned = Html.fromHtml(getString(R.string.android_html_text));
    } else {
        spanned = Html.fromHtml(getString(R.string.android_html_text), Html.FROM_HTML_MODE_COMPACT);
    }

    SpannableStringBuilder builder = new SpannableStringBuilder(spanned);

    StyleSpan[] styleSpanArray = builder.getSpans(0, builder.length(), StyleSpan.class);
    SuperscriptSpan[] superscriptSpanArray = builder.getSpans(0, builder.length(), SuperscriptSpan.class);

    mCreateTypeface();
    mCustomiseStyleSpan(styleSpanArray, builder);
    mCustomiseScriptSpan(superscriptSpanArray, builder);

    TextView textView = (TextView)findViewById(R.id.text_view);
    textView.setTypeface(mRegularTypeface);
    textView.setText(builder, TextView.BufferType.SPANNABLE);
}
 
开发者ID:andrei-egeniq,项目名称:android-tibits,代码行数:27,代码来源:MainActivity.java

示例3: handleEndTag

import android.text.style.SuperscriptSpan; //导入依赖的package包/类
private void handleEndTag(CharacterStyle style) {
    if (style instanceof URLSpan) {
        mOut.append("</a>");
    } else if (style instanceof TypefaceSpan) {
        mOut.append("</font>");
    } else if (style instanceof ForegroundColorSpan) {
        mOut.append("</font>");
    } else if (style instanceof BackgroundColorSpan) {
        mOut.append("</font>");
    } else if (style instanceof AbsoluteSizeSpan) {
        mOut.append("</font>");
    } else if (style instanceof StrikethroughSpan) {
        mOut.append("</strike>");
    } else if (style instanceof SubscriptSpan) {
        mOut.append("</sub>");
    } else if (style instanceof SuperscriptSpan) {
        mOut.append("</sup>");
    } else if (style instanceof UnderlineSpan) {
        mOut.append("</u>");
    } else if (style instanceof BoldSpan) {
        mOut.append("</b>");
    } else if (style instanceof ItalicSpan) {
        mOut.append("</i>");
    }
}
 
开发者ID:Ronak-LM,项目名称:memoir,代码行数:26,代码来源:ConverterSpannedToHtml.java

示例4: processSup

import android.text.style.SuperscriptSpan; //导入依赖的package包/类
private void processSup( boolean opening, Editable output) {
    int len = output.length();
    if(opening) {
        //output.setSpan(new AbsoluteSizeSpan(scriptSize,false), len, len, Spannable.SPAN_MARK_MARK);
        //output.setSpan(new RelativeSizeSpan(0.5f), len, len, Spannable.SPAN_MARK_MARK);
        output.setSpan(new SuperscriptSpan(), len, len, Spannable.SPAN_MARK_MARK);
    } else {
        Object obj = getLast(output, SuperscriptSpan.class);
        int where = output.getSpanStart(obj);
        output.removeSpan(obj);
        //obj = getLast(output, RelativeSizeSpan.class);
        //output.removeSpan(obj);
        if (where != len&&where>=0) {
            //output.setSpan(new AbsoluteSizeSpan(scriptSize, false), where, len, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
            output.setSpan(new RelativeSizeSpan(0.7f), where, len, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
            output.setSpan(new SuperscriptSpan(), where, len, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
        }
        //obj = getLast(output, AbsoluteSizeSpan.class);
        //where = output.getSpanStart(obj);
        //output.removeSpan(obj);
        //if (where != len) {
        //    output.setSpan(new AbsoluteSizeSpan(scriptSize, false), where, len, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
        //    //output.setSpan(new RelativeSizeSpan(0.5f), where, len, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
        //}
    }
}
 
开发者ID:tianyuan168326,项目名称:nono-android,代码行数:27,代码来源:MyHtmlTagHandler.java

示例5: onFinishInflate

import android.text.style.SuperscriptSpan; //导入依赖的package包/类
@Override
protected void onFinishInflate() {
    super.onFinishInflate();
    ((TextView) findViewById(R.id.item_new).findViewById(R.id.rank))
            .append(makeAsteriskSpan());
    SpannableString spannable = new SpannableString("+5");
    spannable.setSpan(new SuperscriptSpan(), 0, spannable.length(),
            Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
    spannable.setSpan(new RelativeSizeSpan(0.6f), 0, spannable.length(),
            Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
    spannable.setSpan(new ForegroundColorSpan(
            ContextCompat.getColor(getContext(), R.color.greenA700)), 0, spannable.length(),
            Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
    ((TextView) findViewById(R.id.item_promoted).findViewById(R.id.rank)).append(spannable);
    TextView comments = (TextView) findViewById(R.id.item_new_comments).findViewById(R.id.comment);
    SpannableStringBuilder sb = new SpannableStringBuilder("46");
    sb.append(makeAsteriskSpan());
    comments.setText(sb);
}
 
开发者ID:hidroh,项目名称:materialistic,代码行数:20,代码来源:HelpListView.java

示例6: testCharSequence

import android.text.style.SuperscriptSpan; //导入依赖的package包/类
@Test
public void testCharSequence() {

    final Spannable.Factory factory = Spannable.Factory.getInstance();

    final Spannable single = factory.newSpannable("Hello Single Spannable");
    single.setSpan(new UnderlineSpan(), 0, single.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);

    final Spannable s1 = factory.newSpannable("S1");
    s1.setSpan(new SuperscriptSpan(), 0, s1.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);

    final Spannable s2 = factory.newSpannable("[email protected]_dskfjsjdhfkjf");
    s2.setSpan(new StrikethroughSpan(), 0, s2.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);

    final SomeParcelableSibling sibling = new SomeParcelableSibling()
            .setCharSequence(single)
            .setCharSequenceArray(new CharSequence[]{s1, s2});

    assertParcelable(sibling, false);
}
 
开发者ID:noties,项目名称:ParcelGen,代码行数:21,代码来源:ParcelGenTest.java

示例7: superscript_should_add_only_one_span

import android.text.style.SuperscriptSpan; //导入依赖的package包/类
@Test
public void superscript_should_add_only_one_span() {
    spanBuilder.style(range, EZ.SUPERSCRIPT)
               .apply();

    verify((SpanEZ) spanBuilder, times(1))
            .addSpan(isA(TargetRange.class), isA(SuperscriptSpan.class));
}
 
开发者ID:yombunker,项目名称:SpanEZ,代码行数:9,代码来源:SpanEZTest.java

示例8: setSuperscriptSpan

import android.text.style.SuperscriptSpan; //导入依赖的package包/类
public MIP_TextStyle setSuperscriptSpan(int start, int end)
{
    if (spannableString == null)
    {
        return this;
    }
    spannableString.setSpan(new SuperscriptSpan(), start, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); // 设置前景色为洋红色
    return this;
}
 
开发者ID:zhuyu1022,项目名称:amap,代码行数:10,代码来源:MIP_TextStyle.java

示例9: ConvertToExponent

import android.text.style.SuperscriptSpan; //导入依赖的package包/类
private SpannableStringBuilder ConvertToExponent(String s) { //This Function makes the Normal text into Exponents and base, position being the index of exponent
    int position = s.indexOf("x") + 1;
    SpannableStringBuilder builder = new SpannableStringBuilder(s);
    builder.setSpan(new SuperscriptSpan(), position, position + 1, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
    builder.setSpan(new RelativeSizeSpan(0.50f), position, position + 1, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
    return builder;
}
 
开发者ID:coder3101,项目名称:Matrix-Calculator-for-Android,代码行数:8,代码来源:FunctionMaker.java

示例10: superscript

import android.text.style.SuperscriptSpan; //导入依赖的package包/类
/**
 * @see SuperscriptSpan#SuperscriptSpan()
 */
public static Span superscript() {
    return new Span(new SpanBuilder() {
        @Override
        public Object build() {
            return new SuperscriptSpan();
        }
    });
}
 
开发者ID:neworld,项目名称:spanner,代码行数:12,代码来源:Spans.java

示例11: superscript

import android.text.style.SuperscriptSpan; //导入依赖的package包/类
/**
 * SuperscriptSpan,设置上标
 */
private void superscript () {
    SpannableString string = new SpannableString("为文字设置下划线");
    RelativeSizeSpan sizeSpan = new RelativeSizeSpan(0.7f);
    string.setSpan(sizeSpan, 5, string.length(), Spanned.SPAN_EXCLUSIVE_INCLUSIVE);
    SuperscriptSpan superscriptSpan = new SuperscriptSpan();
    string.setSpan(superscriptSpan, 5, string.length(), Spanned.SPAN_EXCLUSIVE_INCLUSIVE);
    bgtext.setText(string);
}
 
开发者ID:wuhighway,项目名称:DailyStudy,代码行数:12,代码来源:SpannableStringActivity.java

示例12: setSuperscript

import android.text.style.SuperscriptSpan; //导入依赖的package包/类
public TextDecorator setSuperscript(final String... texts) {
  int index;

  for (String text : texts) {
    if (content.contains(text)) {
      index = content.indexOf(text);
      decoratedContent.setSpan(new SuperscriptSpan(), index, index + text.length(), flags);
    }
  }

  return this;
}
 
开发者ID:nntuyen,项目名称:text-decorator,代码行数:13,代码来源:TextDecorator.java

示例13: fixTimeForHTML

import android.text.style.SuperscriptSpan; //导入依赖的package包/类
public static CharSequence fixTimeForHTML(String time) {
    time = fixTime(time);
    if (!Prefs.use12H()) {
        return time;
    }
    int d = time.indexOf(" ");
    if (d < 0) return time;
    time = time.replace(" ", "");

    int s = time.length();
    Spannable span = new SpannableString(time);
    span.setSpan(new SuperscriptSpan(), d, s, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
    span.setSpan(new RelativeSizeSpan(0.5f), d, s, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
    return span;
}
 
开发者ID:metinkale38,项目名称:prayer-times-android,代码行数:16,代码来源:Utils.java

示例14: genMaxText

import android.text.style.SuperscriptSpan; //导入依赖的package包/类
private CharSequence genMaxText() {
    SpannableStringBuilder ssb = new SpannableStringBuilder(
            String.valueOf(max) + "+");
    RelativeSizeSpan span = new RelativeSizeSpan(.8f);
    // ssb.setSpan(span, 2, 3, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
    SuperscriptSpan span2 = new SuperscriptSpan();
    // ssb.setSpan(span2, 2, 3, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
    return ssb;
}
 
开发者ID:HarryXR,项目名称:SimpleNews,代码行数:10,代码来源:BadgeView2.java

示例15: onSpanClick

import android.text.style.SuperscriptSpan; //导入依赖的package包/类
@Override
public void onSpanClick(SpanButton v) {
    View view=richEdit.findFocus();
    BaseRichEditText editText;
    if(view instanceof BaseRichEditText){
        editText=(BaseRichEditText)view;
    }else {
        return;
    }
    TypedValue typedValue = new TypedValue();
    getContext().getTheme().resolveAttribute(R.attr.colorAccent, typedValue, true);
    int color=typedValue.data;
    switch (v.getSpan()){
        case SpanButton.SPAN_BOLD:editText.toggleBold();if(editText.isBold()){editText.applyStyleSpan(Typeface.BOLD);v.setColor(color);}else {editText.removeSelectionSpan(Typeface.BOLD);v.setColor(0xff757575);}break;
        case SpanButton.SPAN_ITALIC:editText.toggleItalic();if(editText.isItalic()){editText.applyStyleSpan(Typeface.ITALIC);v.setColor(color);}else {editText.removeSelectionSpan(Typeface.ITALIC);v.setColor(0xff757575);}break;
        case SpanButton.SPAN_STRIKETHROUGH:editText.toggleStrikethrough();if(editText.isStrikethrough()){editText.applySelectionSpan(StrikethroughSpan.class);v.setColor(color);}else {editText.removeSelectionSpan(StrikethroughSpan.class);v.setColor(0xff757575);}break;
        case SpanButton.SPAN_UNDERLINE:editText.toggleUnderLine();if(editText.isUnderLine()){editText.applySelectionSpan(UnderlineSpan.class);v.setColor(color);}else {editText.removeSelectionSpan(UnderlineSpan.class);v.setColor(0xff757575);}break;
        case SpanButton.SPAN_FOREGROUND:editText.toggleForegroundColor();if(editText.isForegroundColor()){editText.applyColorSpan(ForegroundColorSpan.class,v.getGroundColor());v.setColor(v.getGroundColor());}else {editText.removeSelectionSpan(ForegroundColorSpan.class);v.setColor(0xff757575);}break;
        case SpanButton.SPAN_BACKGROUND:editText.toggleBackgroundColor();if(editText.isBackgroundColor()){editText.applyColorSpan(BackgroundColorSpan.class,v.getGroundColor());v.setColor(v.getGroundColor());}else {editText.removeSelectionSpan(BackgroundColorSpan.class);v.setColor(0xff757575);}break;
        case SpanButton.SPAN_SUBSCRIPT:editText.toggleSubscript();if(editText.isSubscript()){editText.applyScriptSpan(SubscriptSpan.class);v.setColor(color);}else {editText.removeSelectionSpan(SubscriptSpan.class);v.setColor(0xff757575);}break;
        case SpanButton.SPAN_SUPERSCRIPT:editText.toggleSuperscript();if(editText.isSuperscript()){editText.applyScriptSpan(SuperscriptSpan.class);v.setColor(color);}else {editText.removeSelectionSpan(SuperscriptSpan.class);v.setColor(0xff757575);}break;
        case SpanButton.SPAN_TODO:richEdit.addTodoLayout((BaseContainer) richEdit.findFocus().getParent().getParent());break;
        case SpanButton.SPAN_DOT:richEdit.addDotLayout((BaseContainer) richEdit.findFocus().getParent().getParent());break;
        case SpanButton.SPAN_NUMERIC:richEdit.addNumericLayout((BaseContainer) richEdit.findFocus().getParent().getParent());break;
        case SpanButton.SPAN_PHOTO:richEdit.addPhotoLayout((BaseContainer) richEdit.findFocus().getParent().getParent());break;
        //case SpanButton.SPAN_TEXTSIZE:editText.changeSize();editText.applyRelativeSpan();break;
        //case SpanButton.SPAN_BOLD:editText.toggleBold();if(editText.isBold()){editText.applyStyleSpan(Typeface.BOLD);v.setColor(color);}else {editText.removeSelectionSpan(Typeface.BOLD);v.setColor(0xff757575);}break;
    }
}
 
开发者ID:tianyuan168326,项目名称:nono-android,代码行数:30,代码来源:EditView.java


注:本文中的android.text.style.SuperscriptSpan类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。