I need textview where first letter is big capatalized like on the photo. What is the best library or solution to achieve that?
Asked
Active
Viewed 274 times
-3
-
4The big letter is called a drop cap. https://android-arsenal.com/details/1/3664, https://github.com/novoda/spikes/tree/master/drop-cap – Nicolas May 10 '17 at 11:38
-
thanks man it works for me – Евгений Речков May 10 '17 at 11:44
2 Answers
1
You can use SpannableString
without using any library.
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);
You can use your text in title
variable.

Piyush
- 18,895
- 5
- 32
- 63
-
It's good solution but first letter behavious not like on the image. – Евгений Речков May 10 '17 at 13:09
1
1. Add following dependency in app/build.gradle
compile 'com.github.rpradal.lettrine:lettrine:release_number'
2. Use 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" />
For more help, please follow this link
Result will be as:

PEHLAJ
- 9,980
- 9
- 41
- 53