本文整理匯總了Java中android.text.style.SubscriptSpan類的典型用法代碼示例。如果您正苦於以下問題:Java SubscriptSpan類的具體用法?Java SubscriptSpan怎麽用?Java SubscriptSpan使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
SubscriptSpan類屬於android.text.style包,在下文中一共展示了SubscriptSpan類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: setPenAttr
import android.text.style.SubscriptSpan; //導入依賴的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;
}
}
示例2: handleEndTag
import android.text.style.SubscriptSpan; //導入依賴的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>");
}
}
示例3: subscript_should_add_only_one_span
import android.text.style.SubscriptSpan; //導入依賴的package包/類
@Test
public void subscript_should_add_only_one_span() {
spanBuilder.style(range, EZ.SUBSCRIPT)
.apply();
verify((SpanEZ) spanBuilder, times(1))
.addSpan(isA(TargetRange.class), isA(SubscriptSpan.class));
}
示例4: setSubscriptSpan
import android.text.style.SubscriptSpan; //導入依賴的package包/類
public MIP_TextStyle setSubscriptSpan(int start, int end)
{
if (spannableString == null)
{
return this;
}
spannableString.setSpan(new SubscriptSpan(), start, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); // 設置前景色為洋紅色
return this;
}
示例5: subscript
import android.text.style.SubscriptSpan; //導入依賴的package包/類
/**
* @see SubscriptSpan#SubscriptSpan()
*/
public static Span subscript() {
return new Span(new SpanBuilder() {
@Override
public Object build() {
return new SubscriptSpan();
}
});
}
示例6: subscript
import android.text.style.SubscriptSpan; //導入依賴的package包/類
/**
* SubscriptSpan,設置下標
*/
private void subscript () {
SpannableString string = new SpannableString("為文字設置下劃線");
RelativeSizeSpan sizeSpan = new RelativeSizeSpan(0.7f);
string.setSpan(sizeSpan, 5, string.length(), Spanned.SPAN_EXCLUSIVE_INCLUSIVE);
SubscriptSpan superscriptSpan = new SubscriptSpan();
string.setSpan(superscriptSpan, 5, string.length(), Spanned.SPAN_EXCLUSIVE_INCLUSIVE);
bgtext.setText(string);
}
示例7: setSubscript
import android.text.style.SubscriptSpan; //導入依賴的package包/類
public TextDecorator setSubscript(final String... texts) {
int index;
for (String text : texts) {
if (content.contains(text)) {
index = content.indexOf(text);
decoratedContent.setSpan(new SubscriptSpan(), index, index + text.length(), flags);
}
}
return this;
}
示例8: attachToView
import android.text.style.SubscriptSpan; //導入依賴的package包/類
public void attachToView(ViewGroup targetView) {
for (int i = 0; i < 3; ++i) {
ViewGroup g = (ViewGroup) targetView.getChildAt(i);
TextView label = (TextView) g.getChildAt(0);
Slider slider = (Slider) g.getChildAt(1);
TextView valueText = (TextView) g.getChildAt(2);
SliderPositionListener positionListener = new LedValueUpdater(valueText, i);
slider.setPositionListener(positionListener);
LabelClickListener leftLabelListener = new LabelClickListener(slider, 0);
label.setOnClickListener(leftLabelListener);
LabelClickListener rightLabelListener = new LabelClickListener(slider, 1);
valueText.setOnClickListener(rightLabelListener);
valueText.setText("0");
if (i == 0) {
String labelText = "Led";
SpannableStringBuilder ssb = new SpannableStringBuilder(labelText);
ssb.append(String.valueOf(mLEDNumber));
int spanStart = labelText.length();
int spanEnd = spanStart + 1;
ssb.setSpan(new SubscriptSpan(), spanStart, spanEnd, 0);
ssb.setSpan(new RelativeSizeSpan(0.7f), spanStart, spanEnd, 0);
label.setText(ssb);
slider.setSliderBackground(mRed);
} else {
label.setText("");
if (i == 1) {
slider.setSliderBackground(mGreen);
} else {
slider.setSliderBackground(mBlue);
}
}
}
}
示例9: onSpanClick
import android.text.style.SubscriptSpan; //導入依賴的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;
}
}
示例10: processSub
import android.text.style.SubscriptSpan; //導入依賴的package包/類
private void processSub( boolean opening, Editable output) {
int len = output.length();
if(opening) {
//output.setSpan(new RelativeSizeSpan(0.5f), len, len, Spannable.SPAN_MARK_MARK);
output.setSpan(new SubscriptSpan(), len, len, Spannable.SPAN_MARK_MARK);
//output.setSpan(new AbsoluteSizeSpan(scriptSize,false), len, len, Spannable.SPAN_MARK_MARK);
} else {
Object obj = getLast(output, SubscriptSpan.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 SubscriptSpan(), 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);
// }
}
}
示例11: showSubscriptSpan
import android.text.style.SubscriptSpan; //導入依賴的package包/類
/**
* 設置文字下標
*/
private void showSubscriptSpan()
{
TextView tvSubScriptSpan = (TextView) findViewById(R.id.tv_subscript_span);
SpannableString spannableString = new SpannableString("這是第七行設置文字下標:CO2");
SubscriptSpan subscriptSpan = new SubscriptSpan();
spannableString.setSpan(subscriptSpan, spannableString.length()-1, spannableString.length(), Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
tvSubScriptSpan.setText(spannableString);
}
示例12: setUpSubscriptSpan
import android.text.style.SubscriptSpan; //導入依賴的package包/類
private static void setUpSubscriptSpan(Span span, SpannableString ss, int start, int end) {
if (span.isSubscript()) {
ss.setSpan(
new SubscriptSpan(),
start,
end,
Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
}
}
示例13: subscript
import android.text.style.SubscriptSpan; //導入依賴的package包/類
public static Node subscript(Object... nodes) {
return new SpanNode(new SubscriptSpan(), nodes);
}
示例14: handleTagNode
import android.text.style.SubscriptSpan; //導入依賴的package包/類
@Override public void handleTagNode(TagNode node, SpannableStringBuilder builder, int start, int end) {
builder.setSpan(new SubscriptSpan(), start, end, 33);
builder.setSpan(new RelativeSizeSpan(0.8f), start, end, 33);
}
示例15: handleTagNode
import android.text.style.SubscriptSpan; //導入依賴的package包/類
public void handleTagNode(TagNode node, SpannableStringBuilder builder,
int start, int end, SpanStack spanStack) {
spanStack.pushSpan(new SubscriptSpan(), start, end);
}