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


Java UnderlineSpan类代码示例

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


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

示例1: applySpansForTag

import android.text.style.UnderlineSpan; //导入依赖的package包/类
private static void applySpansForTag(StartTag startTag, SpannableStringBuilder spannedText) {
  switch(startTag.name) {
    case TAG_BOLD:
      spannedText.setSpan(new StyleSpan(STYLE_BOLD), startTag.position,
          spannedText.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
      return;
    case TAG_ITALIC:
      spannedText.setSpan(new StyleSpan(STYLE_ITALIC), startTag.position,
          spannedText.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
      return;
    case TAG_UNDERLINE:
      spannedText.setSpan(new UnderlineSpan(), startTag.position,
          spannedText.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
      return;
    default:
      break;
  }
}
 
开发者ID:MLNO,项目名称:airgram,代码行数:19,代码来源:WebvttCueParser.java

示例2: undo

import android.text.style.UnderlineSpan; //导入依赖的package包/类
public void undo() {
    EditItem edit = mEditHistory.getPrevious();
    if (edit == null) {
        return;
    }

    Editable editable = mTextView.getEditableText();
    int start = edit.start;
    int end = start + (edit.after != null ? edit.after.length() : 0);

    mIsUndoOrRedo = true;
    editable.replace(start, end, edit.before);
    mIsUndoOrRedo = false;

    for (Object o : editable.getSpans(0, editable.length(), UnderlineSpan.class)) {
        editable.removeSpan(o);
    }

    Selection.setSelection(editable, edit.before == null ? start : (start + edit.before.length()));
}
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:21,代码来源:UndoRedoSupportEditText.java

示例3: redo

import android.text.style.UnderlineSpan; //导入依赖的package包/类
public void redo() {
    EditItem edit = mEditHistory.getNext();
    if (edit == null) {
        return;
    }

    Editable text = mTextView.getEditableText();
    int start = edit.start;
    int end = start + (edit.before != null ? edit.before.length() : 0);

    mIsUndoOrRedo = true;
    text.replace(start, end, edit.after);
    mIsUndoOrRedo = false;

    // This will get rid of underlines inserted when editor tries to come
    // up with a suggestion.
    for (Object o : text.getSpans(0, text.length(), UnderlineSpan.class)) {
        text.removeSpan(o);
    }

    Selection.setSelection(text, edit.after == null ? start
            : (start + edit.after.length()));
}
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:24,代码来源:UndoRedoSupportEditText.java

示例4: undo

import android.text.style.UnderlineSpan; //导入依赖的package包/类
public void undo() {
    EditItem edit = mEditHistory.getPrevious();
    if (edit == null) {
        return;
    }

    Editable editable = mTextView.getEditableText();
    int start = edit.start;
    int end = start + (edit.after != null ? edit.after.length() : 0);

    mIsUndoOrRedo = true;
    editable.replace(start, end, edit.before);
    mIsUndoOrRedo = false;

    for (Object o : editable.getSpans(0, editable.length(), UnderlineSpan.class)) {
        editable.removeSpan(o);
    }

    Selection.setSelection(editable,
            edit.before == null ? start : (start + edit.before.length()));
}
 
开发者ID:Light-Team,项目名称:ModPE-IDE-Source,代码行数:22,代码来源:UndoRedoHelper.java

示例5: attachFontFace

import android.text.style.UnderlineSpan; //导入依赖的package包/类
private static void attachFontFace(SpannableStringBuilder cueText, int fontFace,
    int defaultFontFace, int start, int end, int spanPriority) {
  if (fontFace != defaultFontFace) {
    final int flags = Spanned.SPAN_EXCLUSIVE_EXCLUSIVE | spanPriority;
    boolean isBold = (fontFace & FONT_FACE_BOLD) != 0;
    boolean isItalic = (fontFace & FONT_FACE_ITALIC) != 0;
    if (isBold) {
      if (isItalic) {
        cueText.setSpan(new StyleSpan(Typeface.BOLD_ITALIC), start, end, flags);
      } else {
        cueText.setSpan(new StyleSpan(Typeface.BOLD), start, end, flags);
      }
    } else if (isItalic) {
      cueText.setSpan(new StyleSpan(Typeface.ITALIC), start, end, flags);
    }
    boolean isUnderlined = (fontFace & FONT_FACE_UNDERLINE) != 0;
    if (isUnderlined) {
      cueText.setSpan(new UnderlineSpan(), start, end, flags);
    }
    if (!isUnderlined && !isBold && !isItalic) {
      cueText.setSpan(new StyleSpan(Typeface.NORMAL), start, end, flags);
    }
  }
}
 
开发者ID:sanjaysingh1990,项目名称:Exoplayer2Radio,代码行数:25,代码来源:Tx3gDecoder.java

示例6: testTextDecorationLineUnderlineApplied

import android.text.style.UnderlineSpan; //导入依赖的package包/类
@Test
public void testTextDecorationLineUnderlineApplied() {
  UIManagerModule uiManager = getUIManagerModule();

  ReactRootView rootView = createText(
      uiManager,
      JavaOnlyMap.of(ViewProps.TEXT_DECORATION_LINE, "underline"),
      JavaOnlyMap.of(ReactTextShadowNode.PROP_TEXT, "test text"));

  TextView textView = (TextView) rootView.getChildAt(0);
  Spanned text = (Spanned) textView.getText();
  UnderlineSpan underlineSpan = getSingleSpan(textView, UnderlineSpan.class);
  StrikethroughSpan[] strikeThroughSpans =
      text.getSpans(0, text.length(), StrikethroughSpan.class);
  assertThat(underlineSpan instanceof UnderlineSpan).isTrue();
  assertThat(strikeThroughSpans).hasSize(0);
}
 
开发者ID:qq565999484,项目名称:RNLearn_Project1,代码行数:18,代码来源:ReactTextTest.java

示例7: testTextDecorationLineLineThroughApplied

import android.text.style.UnderlineSpan; //导入依赖的package包/类
@Test
public void testTextDecorationLineLineThroughApplied() {
  UIManagerModule uiManager = getUIManagerModule();

  ReactRootView rootView = createText(
      uiManager,
      JavaOnlyMap.of(ViewProps.TEXT_DECORATION_LINE, "line-through"),
      JavaOnlyMap.of(ReactTextShadowNode.PROP_TEXT, "test text"));

  TextView textView = (TextView) rootView.getChildAt(0);
  Spanned text = (Spanned) textView.getText();
  UnderlineSpan[] underlineSpans =
      text.getSpans(0, text.length(), UnderlineSpan.class);
  StrikethroughSpan strikeThroughSpan =
      getSingleSpan(textView, StrikethroughSpan.class);
  assertThat(underlineSpans).hasSize(0);
  assertThat(strikeThroughSpan instanceof StrikethroughSpan).isTrue();
}
 
开发者ID:qq565999484,项目名称:RNLearn_Project1,代码行数:19,代码来源:ReactTextTest.java

示例8: testTextDecorationLineUnderlineLineThroughApplied

import android.text.style.UnderlineSpan; //导入依赖的package包/类
@Test
public void testTextDecorationLineUnderlineLineThroughApplied() {
  UIManagerModule uiManager = getUIManagerModule();

  ReactRootView rootView = createText(
      uiManager,
      JavaOnlyMap.of(ViewProps.TEXT_DECORATION_LINE, "underline line-through"),
      JavaOnlyMap.of(ReactTextShadowNode.PROP_TEXT, "test text"));

  UnderlineSpan underlineSpan =
      getSingleSpan((TextView) rootView.getChildAt(0), UnderlineSpan.class);
  StrikethroughSpan strikeThroughSpan =
      getSingleSpan((TextView) rootView.getChildAt(0), StrikethroughSpan.class);
  assertThat(underlineSpan instanceof UnderlineSpan).isTrue();
  assertThat(strikeThroughSpan instanceof StrikethroughSpan).isTrue();
}
 
开发者ID:qq565999484,项目名称:RNLearn_Project1,代码行数:17,代码来源:ReactTextTest.java

示例9: setPenAttr

import android.text.style.UnderlineSpan; //导入依赖的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

示例10: handleEndTag

import android.text.style.UnderlineSpan; //导入依赖的package包/类
private void handleEndTag(String tag) {
    if (tag.equalsIgnoreCase("br")) {
        handleBr(mSpannableStringBuilder);
    } else if (tag.equalsIgnoreCase("p")) {
        handleP(mSpannableStringBuilder);
    } else if (tag.equalsIgnoreCase("b")) {
        end(mSpannableStringBuilder, Bold.class, new StyleSpan(Typeface.BOLD));
    } else if (tag.equalsIgnoreCase("i")) {
        end(mSpannableStringBuilder, Italic.class, new StyleSpan(Typeface.ITALIC));
    } else if (tag.equalsIgnoreCase("font")) {
        endFont(mSpannableStringBuilder);
    } else if (tag.equalsIgnoreCase("blockquote")) {
        handleP(mSpannableStringBuilder);
        end(mSpannableStringBuilder, Blockquote.class, new QuoteSpan());
    } else if (tag.equalsIgnoreCase("tt")) {
        end(mSpannableStringBuilder, Monospace.class,
                new TypefaceSpan("monospace"));
    } else if (tag.equalsIgnoreCase("u")) {
        end(mSpannableStringBuilder, Underline.class, new UnderlineSpan());
    } else if (mTagHandler != null) {
        mTagHandler.handleTag(false, tag, mSpannableStringBuilder, mReader);
    }
}
 
开发者ID:elibo,项目名称:ScribaNotesApp,代码行数:24,代码来源:Html.java

示例11: clearTitle

import android.text.style.UnderlineSpan; //导入依赖的package包/类
public void clearTitle() {

        ssbTitle = (SpannableStringBuilder) noteTitleText.getText();
        StyleSpan[] ss = ssbTitle.getSpans(noteTitleText.getSelectionStart(), noteTitleText.getSelectionEnd(), StyleSpan.class);
        UnderlineSpan[] us = ssbTitle.getSpans(noteTitleText.getSelectionStart(), noteTitleText.getSelectionEnd(), UnderlineSpan.class);
        BackgroundColorSpan[] bgSpan = ssbTitle.getSpans(noteTitleText.getSelectionStart(), noteTitleText.getSelectionEnd(), BackgroundColorSpan.class);

        for (int i = 0; i < bgSpan.length; i++) {
            ssbTitle.removeSpan(bgSpan[i]);
        }

        for (int i = 0; i < ss.length; i++) {
            if (ss[i].getStyle() == Typeface.BOLD_ITALIC || ss[i].getStyle() == Typeface.BOLD || ss[i].getStyle() == Typeface.ITALIC) {
                ssbTitle.removeSpan(ss[i]);
            }
        }

        for (int i = 0; i < us.length; i++) {
            ssbTitle.removeSpan(us[i]);
        }

        noteTitleText.setText(ssbTitle);

    }
 
开发者ID:elibo,项目名称:ScribaNotesApp,代码行数:25,代码来源:EditNoteActivity.java

示例12: clearContent

import android.text.style.UnderlineSpan; //导入依赖的package包/类
public void clearContent() {

        ssbContent = (SpannableStringBuilder) noteContentText.getText();
        StyleSpan[] ss = ssbContent.getSpans(noteContentText.getSelectionStart(), noteContentText.getSelectionEnd(), StyleSpan.class);
        UnderlineSpan[] us = ssbContent.getSpans(noteContentText.getSelectionStart(), noteContentText.getSelectionEnd(), UnderlineSpan.class);
        BackgroundColorSpan[] bgSpan = ssbContent.getSpans(noteContentText.getSelectionStart(), noteContentText.getSelectionEnd(), BackgroundColorSpan.class);

        for (int i = 0; i < ss.length; i++) {
            if (ss[i].getStyle() == Typeface.BOLD_ITALIC || ss[i].getStyle() == Typeface.BOLD || ss[i].getStyle() == Typeface.ITALIC) {
                ssbContent.removeSpan(ss[i]);
            }
        }

        for (int i = 0; i < us.length; i++) {
            ssbContent.removeSpan(us[i]);
        }

        for (int i = 0; i < bgSpan.length; i++) {
            ssbContent.removeSpan(bgSpan[i]);
        }

        noteContentText.setText(ssbContent);
    }
 
开发者ID:elibo,项目名称:ScribaNotesApp,代码行数:24,代码来源:EditNoteActivity.java

示例13: boldItalicText

import android.text.style.UnderlineSpan; //导入依赖的package包/类
public void boldItalicText() {
    tags(false);
    if (noteContentText.hasSelection()) {

        ssbContent = (SpannableStringBuilder) noteContentText.getText();
        ssbContent.setSpan(new UnderlineSpan(), noteContentText.getSelectionStart(), noteContentText.getSelectionEnd(), 0);
        ssbContent.setSpan(new StyleSpan(Typeface.BOLD_ITALIC), noteContentText.getSelectionStart(), noteContentText.getSelectionEnd(), 0);

    } else if (noteTitleText.hasSelection()) {

        ssbTitle = (SpannableStringBuilder) noteTitleText.getText();
        ssbTitle.setSpan(new UnderlineSpan(), noteTitleText.getSelectionStart(), noteTitleText.getSelectionEnd(), 0);
        ssbTitle.setSpan(new StyleSpan(Typeface.BOLD_ITALIC), noteTitleText.getSelectionStart(), noteTitleText.getSelectionEnd(), 0);

    }
}
 
开发者ID:elibo,项目名称:ScribaNotesApp,代码行数:17,代码来源:EditNoteActivity.java

示例14: testParseStrictValidClassesAndTrailingTokens

import android.text.style.UnderlineSpan; //导入依赖的package包/类
public void testParseStrictValidClassesAndTrailingTokens() throws Exception {
  Spanned text = parseCueText("<v.first.loud Esme>"
      + "This <u.style1.style2 some stuff>is</u> text with <b.foo><i.bar>html</i></b> tags");

  assertEquals("This is text with html tags", text.toString());

  UnderlineSpan[] underlineSpans = getSpans(text, UnderlineSpan.class);
  StyleSpan[] styleSpans = getSpans(text, StyleSpan.class);
  assertEquals(1, underlineSpans.length);
  assertEquals(2, styleSpans.length);
  assertEquals(Typeface.ITALIC, styleSpans[0].getStyle());
  assertEquals(Typeface.BOLD, styleSpans[1].getStyle());

  assertEquals(5, text.getSpanStart(underlineSpans[0]));
  assertEquals(7, text.getSpanEnd(underlineSpans[0]));
  assertEquals(18, text.getSpanStart(styleSpans[0]));
  assertEquals(18, text.getSpanStart(styleSpans[1]));
  assertEquals(22, text.getSpanEnd(styleSpans[0]));
  assertEquals(22, text.getSpanEnd(styleSpans[1]));
}
 
开发者ID:asifkhan11,项目名称:ExoPlayer-Demo,代码行数:21,代码来源:WebvttCueParserTest.java

示例15: testParseWellFormedUnclosedEndAtCueEnd

import android.text.style.UnderlineSpan; //导入依赖的package包/类
public void testParseWellFormedUnclosedEndAtCueEnd() throws Exception {
  Spanned text = parseCueText("An <u some trailing stuff>unclosed u tag with "
      + "<i>italic</i> inside");

  assertEquals("An unclosed u tag with italic inside", text.toString());

  UnderlineSpan[] underlineSpans = getSpans(text, UnderlineSpan.class);
  StyleSpan[] styleSpans = getSpans(text, StyleSpan.class);
  assertEquals(1, underlineSpans.length);
  assertEquals(1, styleSpans.length);
  assertEquals(Typeface.ITALIC, styleSpans[0].getStyle());

  assertEquals(3, text.getSpanStart(underlineSpans[0]));
  assertEquals(23, text.getSpanStart(styleSpans[0]));
  assertEquals(29, text.getSpanEnd(styleSpans[0]));
  assertEquals(36, text.getSpanEnd(underlineSpans[0]));
}
 
开发者ID:asifkhan11,项目名称:ExoPlayer-Demo,代码行数:18,代码来源:WebvttCueParserTest.java


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