I want to create a Layout with special property for displaying text. Let's say I have a long paragraph of up to 6 lines to display on an app. Up till now, text view would be great, but I need specific words to be with special style/design without damaging the paragraph, meaning that I don't want it to be shifted or indented.

So first, the simple linear layout won't be great since it will create indention vertical or horizontally depends on what linear layout it is.

For example, let's say I have this example:

Image

As you can see, the yellow square is the word with the special style

Solving it by simple linear layout ( horizontal or vertical) would looks like this:

Image

So I thought to divide each line into the separate horizontal layout, but that would be only possible If I know how many words fit into each line, but that would be wrong programming since this depends on which phone the app been installed in.

Code only to demonstrate the concept:

 //This would be the outside layout which contains the whole paragraph
<Linear layout Android orientation: vertical>
    //First line 
    <Linear layout Android orientation:horizontal>
         //First section of the line up to the problematic word
         <Text view>
         //Problematic word text view
         <Text view>
         //Second part of line - after the problematic word
         <Text view>
    </Linear layout>
 </Linear layout>

But as I said before that would demand knowing how many words fits each line.

I open to suggestions about this one, as I thought there will be so simple solution.

0 Answers