本文整理汇总了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;
}
示例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);
}
}
}
示例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);
}
}
示例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);
}
}
示例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;
}
示例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");
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
示例11: getAlignmentSpan
import android.text.style.AlignmentSpan; //导入方法依赖的package包/类
private static AlignmentSpan getAlignmentSpan(int align) {
return new AlignmentSpan.Standard(getAlignment(align));
}
示例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");
}
}
}
}
示例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;
}
示例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;
}