-3

I need textview where first letter is big capatalized like on the photo. What is the best library or solution to achieve that?

enter image description here

PEHLAJ
  • 9,980
  • 9
  • 41
  • 53

2 Answers2

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
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:

enter image description here

PEHLAJ
  • 9,980
  • 9
  • 41
  • 53