Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Insert drop caps text in android

Tags:

android

I am learning Android and the following is part of an assignment.

I need to write some text in an Android layout with the first letter in drop caps, like the following text:

enter image description here

I looked up the web and did not find many answers. Is there a style option or some property that I could use?

At the moment, I am thinking of the following options. Please suggest what is the best way to do such a thing

  1. Use an image for the first letter
  2. Write the first letter separately in a big font.

Any suggestions would be helpful.

like image 600
Mukul Goel Avatar asked Feb 28 '14 02:02

Mukul Goel


People also ask

Can you add a drop cap to Google Docs?

You can add a nice decorative element to your document using a drop cap. While Google Docs doesn’t offer a drop-cap feature like Microsoft Word, you can still create one in just a few minutes. A drop cap is the first letter of a word in a paragraph or a block of text.

Is there a way to add caps to text in Android textview?

Following does not apply to TextView, but works with EditText; even then, it applies to the text entered from the keyboard, not the text loaded with setText(). To be more specific, it turns the Caps on in the keyboard, and the user can override this at her will. android:inputType="textCapSentences" or

How do you make a drop cap on a page?

Place your cursor at the beginning of the word in the paragraph or block of text where you want your drop cap to be. You can remove the first letter of the word either before or after you create the drop cap for it. Next, click Insert > Drawing from the menu and choose “New.”

What is a drop cap in writing?

A drop cap is the first letter of a word in a paragraph or a block of text. It’s an upper case letter that’s larger than the rest of the text and can stretch two or more lines. You’ll most often see a drop cap in a book, but it has its place in certain types of documents as well.


Video Answer


2 Answers

You can use a RelativeSizeSpan.

    final String someText = "A long time ago in a galaxy far, far away";
    final SpannableString ss = new SpannableString(someText);
    ss.setSpan(new RelativeSizeSpan(5f), 0, 1, 0);

enter image description here

like image 97
adneal Avatar answered Oct 07 '22 08:10

adneal


There's a library written by Novoda in which you can add a DropCap https://github.com/novoda/spikes/tree/master/drop-cap Here's an image from the demo app:

enter image description here

like image 26
MechaRyRy Avatar answered Oct 07 '22 08:10

MechaRyRy