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


Java AlignmentSpan.Standard方法代码示例

本文整理汇总了Java中android.text.style.AlignmentSpan.Standard方法的典型用法代码示例。如果您正苦于以下问题:Java AlignmentSpan.Standard方法的具体用法?Java AlignmentSpan.Standard怎么用?Java AlignmentSpan.Standard使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.text.style.AlignmentSpan的用法示例。


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

示例1: align

import android.text.style.AlignmentSpan; //导入方法依赖的package包/类
/**
 * add alignment for text
 *
 * @param indent LEFT, RIGHT, CENTER
 * @return Snippety
 */
public Snippety align(Indent indent) {
    AlignmentSpan span;
    switch (indent) {
        case RIGHT:
            span = new AlignmentSpan.Standard(Layout.Alignment.ALIGN_OPPOSITE);
            break;
        case CENTER:
            span = new AlignmentSpan.Standard(Layout.Alignment.ALIGN_CENTER);
            break;
        case LEFT:
        default:
            span = new AlignmentSpan.Standard(Layout.Alignment.ALIGN_NORMAL);
            break;
    }

    spans.add(span);

    return this;
}
 
开发者ID:Fueled,项目名称:snippety,代码行数:26,代码来源:Snippety.java

示例2: handleTag

import android.text.style.AlignmentSpan; //导入方法依赖的package包/类
@Override
protected void handleTag(boolean opening, String tag, Map<String, String> attrs, Editable output) {
    if ("span".equalsIgnoreCase(tag)) {
        if (opening) {
            Span mark = null;
            if ("center".equalsIgnoreCase(attrs.get("class"))) {
                mark = new Center();
                handleP(output);
                start(output, mark);
            }
            spanStack.add(mark);
        } else {
            // Remove.
            Object repl = null;
            Class<? extends Span> kind = Span.class;
            Span span = spanStack.remove(spanStack.size() - 1);
            if (span instanceof Center) {
                handleP(output);
                kind = Center.class;
                repl = new AlignmentSpan.Standard(Layout.Alignment.ALIGN_CENTER);
            }
            end(output, kind, repl);
        }
    }
}
 
开发者ID:labhackercd,项目名称:edm,代码行数:26,代码来源:MessageTagHandler.java

示例3: assertAlignment

import android.text.style.AlignmentSpan; //导入方法依赖的package包/类
private void assertAlignment(Spannable spannable, Layout.Alignment alignment) {
  if (alignment != null) {
    AlignmentSpan.Standard[] alignmentSpans =
        spannable.getSpans(0, spannable.length(), AlignmentSpan.Standard.class);
    assertEquals(1, alignmentSpans.length);
    assertEquals(alignment, alignmentSpans[0].getAlignment());
  } else {
    assertEquals(0, spannable.getSpans
        (0, spannable.length(), AlignmentSpan.Standard.class).length);
  }
}
 
开发者ID:asifkhan11,项目名称:ExoPlayer-Demo,代码行数:12,代码来源:TtmlParserTest.java

示例4: writeSingleParagraphStyle

import android.text.style.AlignmentSpan; //导入方法依赖的package包/类
private void writeSingleParagraphStyle(ParagraphStyle style, DataOutputStream dos) throws IOException {
    Class clazz = style.getClass();
    dos.writeInt(mString.getSpanStart(style));
    dos.writeInt(mString.getSpanEnd(style));
    dos.writeInt(mString.getSpanFlags(style));
    if (mCharacterStylesTags.containsKey(clazz.getSimpleName())) {
        int tag = mCharacterStylesTags.get(clazz.getSimpleName());
        if (mCharacterStylesTags.containsKey(clazz.getSimpleName())) {
            dos.writeInt(tag);
        }
        switch (tag) {
            case 24: // AligmentSpan.Standard
                AlignmentSpan.Standard as2 = (AlignmentSpan.Standard)style;
                dos.writeInt(as2.getAlignment().ordinal());
                break;
            case 25: // BulletSpan
                BulletSpan bs = (BulletSpan)style;
                dos.writeInt(bs.getLeadingMargin(true));
                dos.writeInt(bs.getLeadingMargin(false));

                break;
            case 30: // LeadingMarginSpan.Sandard
                LeadingMarginSpan.Standard lms = (LeadingMarginSpan.Standard)style;
                dos.writeInt(lms.getLeadingMargin(true));
                dos.writeInt(lms.getLeadingMargin(false));
                break;
            case 34: // QuoteSpan
                QuoteSpan qs = (QuoteSpan)style;
                dos.writeInt(qs.getColor());
                break;
            case 36: // TabStopSpan.Standard
                TabStopSpan.Standard tss = (TabStopSpan.Standard)style;
                dos.writeInt(tss.getTabStop());
                break;
            default:
        }
    } else {
        write(style,dos);
    }
}
 
开发者ID:suwhs,项目名称:wATLlib,代码行数:41,代码来源:SpannedSerializator.java

示例5: readSingleParagraph

import android.text.style.AlignmentSpan; //导入方法依赖的package包/类
private SpanPlacementInfo readSingleParagraph(DataInputStream dis) throws IOException {
    SpanPlacementInfo spi = new SpanPlacementInfo();
    spi.start = dis.readInt();
    spi.end = dis.readInt();
    spi.mode = dis.readInt();
    int tag = dis.readInt(); // mCharacterStylesTags.get(clazz.getSimpleName());
    switch (tag) {
        case 24: // AligmentSpan.Standard
            spi.span = new AlignmentSpan.Standard(Alignment.values()[dis.readInt()]);
            break;
        case 25: // BulletSpan
            spi.span = new BulletSpan(dis.readInt());
            dis.readInt(); // skip gap width for other lines
            break;
        case 30: // LeadingMarginSpan.Sandard
            spi.span = new LeadingMarginSpan.Standard(dis.readInt(),dis.readInt());
            break;
        case 34: // QuoteSpan
            spi.span = new QuoteSpan(dis.readInt());
            break;
        case 36: // TabStopSpan.Standard
            spi.span = new TabStopSpan.Standard(dis.readInt());
            break;
        case 80: // RemoteDrawableSpan
            break;
        default:
            spi.span = read(tag,dis);
    }
    return spi;
}
 
开发者ID:suwhs,项目名称:wATLlib,代码行数:31,代码来源:SpannedSerializator.java

示例6: appendGallery

import android.text.style.AlignmentSpan; //导入方法依赖的package包/类
@Override
public void appendGallery(MediaGallery mediaGallery) {
    Editable editableText = mContentEditText.getText();
    if (editableText == null) {
        return;
    }

    int selectionStart = mContentEditText.getSelectionStart();
    int selectionEnd = mContentEditText.getSelectionEnd();

    if (selectionStart > selectionEnd) {
        int temp = selectionEnd;
        selectionEnd = selectionStart;
        selectionStart = temp;
    }

    int line, column = 0;
    if (mContentEditText.getLayout() != null) {
        line = mContentEditText.getLayout().getLineForOffset(selectionStart);
        column = mContentEditText.getSelectionStart() - mContentEditText.getLayout().getLineStart(line);
    }

    if (column != 0) {
        // insert one line break if the cursor is not at the first column
        editableText.insert(selectionEnd, "\n");
        selectionStart = selectionStart + 1;
        selectionEnd = selectionEnd + 1;
    }

    editableText.insert(selectionStart, " ");
    MediaGalleryImageSpan is = new MediaGalleryImageSpan(getActivity(), mediaGallery,
            R.drawable.icon_mediagallery_placeholder);
    editableText.setSpan(is, selectionStart, selectionEnd + 1, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
    AlignmentSpan.Standard as = new AlignmentSpan.Standard(Layout.Alignment.ALIGN_CENTER);
    editableText.setSpan(as, selectionStart, selectionEnd + 1, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
    editableText.insert(selectionEnd + 1, "\n\n");
}
 
开发者ID:ldsddn,项目名称:wordpress_app_android,代码行数:38,代码来源:LegacyEditorFragment.java

示例7: appendText

import android.text.style.AlignmentSpan; //导入方法依赖的package包/类
private void appendText(CharSequence text, Layout.Alignment align) {
  if (text == null || text.toString().trim().length() == 0) {
    return;
  }

  AlignmentSpan span = new AlignmentSpan.Standard(align);
  SpannableString spannableString = new SpannableString(text);
  spannableString.setSpan(span, 0, text.length(), 0);

  if (textView.length() > 0) {
    textView.append("\n\n");
  }
  textView.append(spannableString);
}
 
开发者ID:chiuki,项目名称:advanced-textview,代码行数:15,代码来源:AlignmentSpanActivity.java

示例8: alignCenter

import android.text.style.AlignmentSpan; //导入方法依赖的package包/类
@Override
public StyleEZ alignCenter(@NonNull ParagraphLocator paragraph) {
    AlignmentSpan centerSpan = new AlignmentSpan.Standard(Layout.Alignment.ALIGN_CENTER);
    addMultipleSpan(paragraph, centerSpan);
    return this;
}
 
开发者ID:yombunker,项目名称:SpanEZ,代码行数:7,代码来源:SpanEZ.java

示例9: alignEnd

import android.text.style.AlignmentSpan; //导入方法依赖的package包/类
@Override
public StyleEZ alignEnd(@NonNull ParagraphLocator paragraph) {
    AlignmentSpan oppositeSpan = new AlignmentSpan.Standard(Layout.Alignment.ALIGN_OPPOSITE);
    addMultipleSpan(paragraph, oppositeSpan);
    return this;
}
 
开发者ID:yombunker,项目名称:SpanEZ,代码行数:7,代码来源:SpanEZ.java

示例10: alignStart

import android.text.style.AlignmentSpan; //导入方法依赖的package包/类
@Override
public StyleEZ alignStart(@NonNull ParagraphLocator paragraph) {
    AlignmentSpan normalSpan = new AlignmentSpan.Standard(Layout.Alignment.ALIGN_NORMAL);
    addMultipleSpan(paragraph, normalSpan);
    return this;
}
 
开发者ID:yombunker,项目名称:SpanEZ,代码行数:7,代码来源:SpanEZ.java

示例11: getAlignmentSpan

import android.text.style.AlignmentSpan; //导入方法依赖的package包/类
private static AlignmentSpan getAlignmentSpan(int align) {
    return new AlignmentSpan.Standard(getAlignment(align));
}
 
开发者ID:hsj-xiaokang,项目名称:OSchina_resources_android,代码行数:4,代码来源:RichEditText.java

示例12: startImg

import android.text.style.AlignmentSpan; //导入方法依赖的package包/类
private void startImg(SpannableStringBuilder text, Attributes attributes, WPHtml.ImageGetter img) {
    if (ctx == null) return;

    String src = attributes.getValue("android-uri");

    Bitmap resizedBitmap = null;
    try {
        resizedBitmap = ImageUtils.getWPImageSpanThumbnailFromFilePath(ctx, src, mMaxImageWidth);
        if (resizedBitmap == null && src != null) {
            if (src.contains("video")) {
                resizedBitmap = BitmapFactory.decodeResource(ctx.getResources(), org.wordpress.android.editor.R.drawable.media_movieclip);
            } else {
                resizedBitmap = BitmapFactory.decodeResource(ctx.getResources(), R.drawable.media_image_placeholder);
            }
        }
    } catch (OutOfMemoryError e) {
        CrashlyticsUtils.logException(e, CrashlyticsUtils.ExceptionType.SPECIFIC, AppLog.T.UTILS);
    }

    if (resizedBitmap != null) {
        int len = text.length();
        text.append("\uFFFC");

        Uri curStream = Uri.parse(src);

        if (curStream == null) {
            return;
        }

        WPImageSpan is = new WPImageSpan(ctx, resizedBitmap, curStream);

        // get the MediaFile data from db
        MediaFile mf = WordPress.wpDB.getMediaFile(src, post);
        if (mf != null) {
            is.setMediaFile(mf);
            is.setImageSource(curStream);
            text.setSpan(is, len, text.length(),
                    Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
            AlignmentSpan.Standard as = new AlignmentSpan.Standard(
                    Layout.Alignment.ALIGN_CENTER);
            text.setSpan(as, text.getSpanStart(is), text.getSpanEnd(is),
                    Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
        }
    } else if (post != null) {
        if (post.isLocalDraft()) {
            if (attributes != null) {
                text.append("<img");
                for (int i = 0; i < attributes.getLength(); i++) {
                    String aName = attributes.getLocalName(i); // Attr name
                    if ("".equals(aName))
                        aName = attributes.getQName(i);
                    text.append(" ");
                    text.append(aName + "=\"" + attributes.getValue(i) + "\"");
                }
                text.append(" />\n");
            }
        }
    }
}
 
开发者ID:ldsddn,项目名称:wordpress_app_android,代码行数:60,代码来源:WPHtml.java

示例13: addAlignmentSpan

import android.text.style.AlignmentSpan; //导入方法依赖的package包/类
public SpanOptions addAlignmentSpan(Layout.Alignment align) {
    AlignmentSpan.Standard span = new AlignmentSpan.Standard(align);
    listSpan.add(span);
    return this;
}
 
开发者ID:xujinyang,项目名称:AndroidSpan,代码行数:6,代码来源:SpanOptions.java

示例14: drawAlignmentSpan

import android.text.style.AlignmentSpan; //导入方法依赖的package包/类
/**
 * 标准文本对齐样式
 *
 * @param text
 * @param align "ALIGN_CENTER"、"ALIGN_NORMAL" 或"ALIGN_OPPOSITE"中的之一
 * @return
 */
public AndroidSpan drawAlignmentSpan(String text, Layout.Alignment align) {
    AlignmentSpan.Standard span = new AlignmentSpan.Standard(align);
    drawSpan(text, span);
    return this;
}
 
开发者ID:xujinyang,项目名称:AndroidSpan,代码行数:13,代码来源:AndroidSpan.java


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