1

In my app, I want to parse text via Regex (it's clear) and devide content by text, numbers, and dates then add devided blocks (TextView?) to view and highlight them (+ make them clikable), but don't know which components/views to use, because I need to determine width or/and constrains

here's I make it manual in paint: here's I make it manual in paint

  • thank you! I tried it just now, for selection it's brilliant, but how can I make parts of one TextView clicable, it's one component, while I want few, present nicely in a view. e.g. LinearLayout not good for this task, do we have other options? – Andrew Smirnov Apr 11 '20 at 18:05
  • You can use constraint layout and put textviews next to each other. You can make textviews clickable or unclickable. – MMG Apr 11 '20 at 18:11
  • I tried this, https://i.ibb.co/h28nd1b/image.png how am I supposed to determine text width? calculate it after each addition and rebind - only soution we have? Secondly Text can start from the middle and make few lines, it's impossible to have one TextView for this, how to determine how many words will go for the first part (from middle to the end of string)? looking for ready-to-go component which will do it for me out of the box, is it exist? – Andrew Smirnov Apr 11 '20 at 18:18
  • You can give weight to your edittexts and you can set number of characters in one edittext. – MMG Apr 11 '20 at 18:20
  • yeah but how calculate width of one character? I is thinner than W, by weight your meant LinearLayour? – Andrew Smirnov Apr 11 '20 at 18:53
  • When you have several textviews in a layout, you set weight for them so that sum of them is equal to layout weight. You don't need to calculate width of characters – MMG Apr 11 '20 at 18:56
  • which layout type do u use for that? tried few, I calculated weight as string length, for 2 TextViews, layout weight as sum of them, didn't work - the same result as previous screen – Andrew Smirnov Apr 12 '20 at 08:09
  • You should use textwatcher to see what is in input. Then you can change color of numbers with help of answer of this question: [https://stackoverflow.com/questions/59628149/how-can-we-have-searched-characters-colored-when-we-use-searchview-in-recyclervi](https://stackoverflow.com/questions/59628149/how-can-we-have-searched-characters-colored-when-we-use-searchview-in-recyclervi) For using textwatcher see my answer for this question: [https://stackoverflow.com/questions/60839902/dynamic-leading-text-for-androids-edittext/60843248#60843248](https://stackoverflow.com/questions/60839902/dynamic-le – MMG Apr 12 '20 at 18:53
  • highlighting works as I mention, text won't change, didn't get the point why do I need to watch it for change. I'm gonna have many text views, the question is how to put them in view to make it good looking like img in question – Andrew Smirnov Apr 13 '20 at 07:39
  • SOLUTION: finally resolved by https://github.com/google/flexbox-layout – Andrew Smirnov Apr 17 '20 at 05:12

0 Answers0