1. 在 app/build.gradle 中添加以下依赖
compile 'com.github.rpradal.lettrine:lettrine:release_number'
2. 使用 LettrineTextView
<com.github.rpradal.lettrine.LettrineTextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
app:lettrine_textColor="@android:color/holo_red_dark"
app:lettrine_text="Lorem ipsum"
app:lettrine_lettrineSize="3"
app:lettrine_textSize="14sp" />
如需更多帮助,请点击此链接
结果如下:
您无需使用任何库即可使用
SpannableString
。
String title = "This is a very good thing. You should try with that and suggest to others";
final SpannableString spannableString = new SpannableString(title);
int position = 0;
for (int i = 0, ei = title.length(); i < ei; i++) {
char c = title.charAt(i);
if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9')) {
position = i;
break;
}
}
spannableString.setSpan(new RelativeSizeSpan(2.0f), position, position + 1, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
txt.setText(spannableString, TextView.BufferType.SPANNABLE);
您可以在
title
变量中使用文本。