0

I have two textboxes side by side and I want that, when the right textbox has more than one line, the other lines start down of the left one. Example below: Example image

The red and the blue lines mark different textboxes, I think they need to be two distinct textboxes because I want their properties to be different.

  • 1
    If that's all the more complicated the formatting will be, it would be simpler to do that with a single `TextView`, using spans to format the text as needed. – Mike M. Jul 13 '20 at 03:16
  • I am newbie in android development. I know spans from HTML, but can it be used in android too? How can I use it? And how do I style a single span inside a text? – Emilio Sanches Jul 13 '20 at 03:21
  • AFAICT, that's basically just a regular sentence with the first word bolded, in a horizontally-centered `TextView`, yeah? You can get the horizontal centering with `android:gravity="center_horizontal"` on the `` element, and there are a couple of ways to bold the first word, but they both do the same thing, ultimately. Have a look at [this post](https://stackoverflow.com/q/14371092). The accepted answer shows the easy way. The top-voted answer shows the "proper" way, which is actually how the first way works, under the hood. – Mike M. Jul 13 '20 at 03:28
  • Hey, I'm here again. If the bold isn't the only one difference between the tow textviews.. what can I do? For example, if I want to change the size of the text – Emilio Sanches Jul 13 '20 at 03:47
  • Yeah, no problem. You can apply as many spans as you want on one string. You should have the general idea of how they work from that top-voted answer; you just need to familiarize yourself with what's available. All the different span types are descendants of [`CharacterStyle`](https://developer.android.com/reference/android/text/style/CharacterStyle), and that page lists the various subclasses that are in the SDK, in the blocks of links towards the top. For sizing, you might want to go with a [`RelativeSizeSpan`](https://developer.android.com/reference/android/text/style/RelativeSizeSpan). – Mike M. Jul 13 '20 at 03:53
  • You could also do that with the "easy" `Html.fromHtml()` method, but that doesn't support everything you could do in real HTML. – Mike M. Jul 13 '20 at 03:56
  • Can you post an answer? So I can accept your answer and vote – Emilio Sanches Jul 13 '20 at 17:39

0 Answers0