本文整理了Java中android.text.SpannableString.<init>()
方法的一些代码示例,展示了SpannableString.<init>()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。SpannableString.<init>()
方法的具体详情如下:
包路径:android.text.SpannableString
类名称:SpannableString
方法名:<init>
暂无
代码示例来源:origin: stackoverflow.com
TextView textView = (TextView) view.findViewById(R.id.textview);
SpannableString content = new SpannableString("Content");
content.setSpan(new UnderlineSpan(), 0, content.length(), 0);
textView.setText(content);
代码示例来源:origin: stackoverflow.com
TextView TV = (TextView)findViewById(R.id.mytextview01);
Spannable wordtoSpan = new SpannableString("I know just how to whisper, And I know just how to cry,I know just where to find the answers");
wordtoSpan.setSpan(new ForegroundColorSpan(Color.BLUE), 15, 30, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
TV.setText(wordtoSpan);
代码示例来源:origin: PhilJay/MPAndroidChart
private SpannableString generateCenterText() {
SpannableString s = new SpannableString("Revenues\nQuarters 2015");
s.setSpan(new RelativeSizeSpan(2f), 0, 8, 0);
s.setSpan(new ForegroundColorSpan(Color.GRAY), 8, s.length(), 0);
return s;
}
}
代码示例来源:origin: stackoverflow.com
String s= "Hello Everyone";
SpannableString ss1= new SpannableString(s);
ss1.setSpan(new RelativeSizeSpan(2f), 0,5, 0); // set size
ss1.setSpan(new ForegroundColorSpan(Color.RED), 0, 5, 0);// set color
TextView tv= (TextView) findViewById(R.id.textview);
tv.setText(ss1);
代码示例来源:origin: mikepenz/Android-Iconics
public void build() {
HashMap<String, ITypeface> mappedFonts = new HashMap<>();
for (ITypeface font : fonts) {
mappedFonts.put(font.getMappingPrefix(), font);
}
//DO NOT STYLE EDITABLE (comes from EditText) as this causes bad issues with the cursor!
/*
if (view.getText() instanceof Editable) {
Iconics.styleEditable(ctx, mappedFonts, (Editable) view.getText(), withStyles, withStylesFor);
} else
*/
if (view.getText() instanceof Spanned) {
view.setText(Iconics.style(ctx, mappedFonts, (Spanned) view.getText(), withStyles, withStylesFor));
} else {
view.setText(Iconics.style(ctx, mappedFonts, new SpannableString(view.getText()), withStyles, withStylesFor));
}
if (view instanceof Button) {
view.setAllCaps(false);
}
}
}
代码示例来源:origin: stackoverflow.com
SpannableString text = new SpannableString("Lorem ipsum dolor sit amet");
// make "Lorem" (characters 0 to 5) red
text.setSpan(new ForegroundColorSpan(Color.RED), 0, 5, 0);
textView.setText(text, BufferType.SPANNABLE);
代码示例来源:origin: stackoverflow.com
String text2 = text + CepVizyon.getPhoneCode() + "\n\n"
+ getText(R.string.currentversion) + CepVizyon.getLicenseText();
Spannable spannable = new SpannableString(text2);
spannable.setSpan(new ForegroundColorSpan(Color.WHITE), text.length(), (text + CepVizyon.getPhoneCode()).length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
myTextView.setText(spannable, TextView.BufferType.SPANNABLE);
代码示例来源:origin: nickbutcher/plaid
static SpannableStringBuilder linkifyPlainLinks(
CharSequence input,
ColorStateList linkTextColor,
@ColorInt int linkHighlightColor) {
final SpannableString plainLinks = new SpannableString(input); // copy of input
// Linkify doesn't seem to work as expected on M+
// TODO: figure out why
//Linkify.addLinks(plainLinks, Linkify.WEB_URLS);
final URLSpan[] urlSpans = plainLinks.getSpans(0, plainLinks.length(), URLSpan.class);
// add any plain links to the output
final SpannableStringBuilder ssb = new SpannableStringBuilder(input);
for (URLSpan urlSpan : urlSpans) {
ssb.removeSpan(urlSpan);
ssb.setSpan(new TouchableUrlSpan(urlSpan.getURL(), linkTextColor, linkHighlightColor),
plainLinks.getSpanStart(urlSpan),
plainLinks.getSpanEnd(urlSpan),
Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
}
return ssb;
}
代码示例来源:origin: stackoverflow.com
String tempString="Copyright";
TextView text=(TextView)findViewById(R.id.text);
SpannableString spanString = new SpannableString(tempString);
spanString.setSpan(new UnderlineSpan(), 0, spanString.length(), 0);
spanString.setSpan(new StyleSpan(Typeface.BOLD), 0, spanString.length(), 0);
spanString.setSpan(new StyleSpan(Typeface.ITALIC), 0, spanString.length(), 0);
text.setText(spanString);
代码示例来源:origin: stackoverflow.com
public class TestActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
TextView textView = (TextView) findViewById(R.id.textview);
SpannableString ss = new SpannableString("abc");
Drawable d = getResources().getDrawable(R.drawable.icon32);
d.setBounds(0, 0, d.getIntrinsicWidth(), d.getIntrinsicHeight());
ImageSpan span = new ImageSpan(d, ImageSpan.ALIGN_BASELINE);
ss.setSpan(span, 0, 3, Spannable.SPAN_INCLUSIVE_EXCLUSIVE);
textView.setText(ss);
}
代码示例来源:origin: stackoverflow.com
TextView tv = (TextView)findViewById(R.id.tv);
Spannable wordtoSpan = new SpannableString("I know just how to whisper, And I know just how to cry,I know just where to find the answers");
wordtoSpan.setSpan(new ForegroundColorSpan(Color.BLUE), 15, 30, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
wordtoSpan.setSpan(new ForegroundColorSpan(Color.RED), 5, 10, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
tv.setText(wordtoSpan);
代码示例来源:origin: stackoverflow.com
SpannableString s = new SpannableString("My Title");
s.setSpan(new TypefaceSpan(this, "MyTypeface.otf"), 0, s.length(),
Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
// Update the action bar title with the TypefaceSpan instance
ActionBar actionBar = getActionBar();
actionBar.setTitle(s);
代码示例来源:origin: yanzhenjie/NoHttp
public static SpannableString getColorText(CharSequence content, int start, int end, int color) {
SpannableString stringSpan = new SpannableString(content);
stringSpan.setSpan(new ForegroundColorSpan(color), start, end, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
return stringSpan;
}
代码示例来源:origin: stackoverflow.com
Spannable WordtoSpan = new SpannableString("I know just how to whisper");
WordtoSpan.setSpan(new ForegroundColorSpan(Color.BLUE), 5, 13,
Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
textview.setText(WordtoSpan);
代码示例来源:origin: stackoverflow.com
TextView tv = (TextView) view.findViewById(R.id.tv);
SpannableString content = new SpannableString("Content");
content.setSpan(new UnderlineSpan(), 0, content.length(), 0);
tv.setText(content);
代码示例来源:origin: eleme/UETool
private void updateSpanTextView() {
TextView spanTextView = findViewById(R.id.span);
SpannableString spannableString = new SpannableString(" 海底捞火锅");
Drawable drawable = ContextCompat.getDrawable(this, R.drawable.ic_food_new);
drawable.setBounds(0, 0, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight());
VerticalImageSpan imageSpan = new VerticalImageSpan(drawable);
spannableString.setSpan(imageSpan, 0, 1, Spannable.SPAN_INCLUSIVE_EXCLUSIVE);
spanTextView.setText(spannableString);
}
代码示例来源:origin: stackoverflow.com
TextView TV = (TextView)findViewById(R.id.mytextview01);
Spannable word = new SpannableString("Your message");
word.setSpan(new ForegroundColorSpan(Color.BLUE), 0, word.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
TV.setText(word);
Spannable wordTwo = new SpannableString("Your new message");
wordTwo.setSpan(new ForegroundColorSpan(Color.RED), 0, wordTwo.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
TV.append(wordTwo);
代码示例来源:origin: Naoki2015/CircleDemo
@NonNull
private SpannableString setClickableSpan(final String textStr, final String id) {
SpannableString subjectSpanText = new SpannableString(textStr);
subjectSpanText.setSpan(new SpannableClickable(itemColor){
@Override
public void onClick(View widget) {
Toast.makeText(MyApplication.getContext(), textStr + " &id = " + id, Toast.LENGTH_SHORT).show();
}
}, 0, subjectSpanText.length(),
Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
return subjectSpanText;
}
代码示例来源:origin: stackoverflow.com
String udata="Underlined Text";
SpannableString content = new SpannableString(udata);
content.setSpan(new UnderlineSpan(), 0, udata.length(), 0);
mTextView.setText(content);
代码示例来源:origin: stackoverflow.com
String firstWord = "first ";
String secondWord = "second";
// Create a new spannable with the two strings
Spannable spannable = new SpannableString(firstWord+secondWord);
// Set the custom typeface to span over a section of the spannable object
spannable.setSpan( new CustomTypefaceSpan("sans-serif",CUSTOM_TYPEFACE), 0, firstWord.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
spannable.setSpan( new CustomTypefaceSpan("sans-serif",SECOND_CUSTOM_TYPEFACE), firstWord.length(), firstWord.length() + secondWord.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
// Set the text of a textView with the spannable object
textView.setText( spannable );
内容来源于网络,如有侵权,请联系作者删除!