I already looked at similar questions, and they deal mostly with scrolling inside a multi line text view, example: How to make a part of long TextView visible on screen? and How do I center text horizontally and vertically in a TextView?
That is not what I want.
For my case I have a list of search results that match the user query. In this list I highlight inside each result the portion of the text that matched the user query. Each item in this list is constrained to 1 line, this means that there are situations where the query match that is highlighted is outside the TextView.
Example:
User searches for "words"
List returns this result:
Lorem Ipsum long text example | with more [words] outside the textview, some of which can be the only match of the user query |
---|
The left cell here represents the visible TextView width, and the right is the rest of the text the user cannot view because it is clipped by the TextView width. Translated into an UI example, this is what the user would see:
| Lorem Ipsum long text example... |
The part of the text that matches the user query "words" is outside the view, and I want to find a way to ensure that this is visible to the user, regardless of the size of the text. Following the example above, this is what I want to do:
| ...with more [words] outside the... |
Basically the text is "scrolled" to a point where the first found match becomes visible to the user, but I do not want to make that view itself scrollable, otherwise the user will be able to scroll each item and that is not my intended goal here.
I see other apps doing something like this, but looking for examples online for such generic search terms has lead me to no solutions.
Any idea how this can be achieved?
EDIT: Adding a visual example of google search ensuring the end of the sentence that matches my search query is visible in the search results, although this is on the web, the example is valid nonetheless.: