Underline text while typing in EditText - Android - java

I am new to android development and was working on a project which involved in underlining specific words in the text field while typing I found an example on dribble which achieves the same thing:
Here I have the index of the word in the string which I want to underline. Is there any way to achieve this? Thank you
Please Note: I don't want to know about how to find the substrings as mentioned in the video but I want to achieve the same underline animation as shown in the video
Is there any way that we can have a canvas behind the EditText and then have the underline animation there??

Related

Dynamically highlighting strings in javaFX

Please read before labelling this as a duplicate.
I am creating an application that calculates how fast a person can type by calculating WPM and CPM. However I have hit a snag with the UI as I found out that you cannot really highlight individual strings in a TextArea. My goal is to compare what the user is typing to the random text that is generated by having it so that the text is being dynamically coloured or highlighted as the user is typing.
See http://10fastfingers.com/typing-test/english to get an idea of what I mean
I recently read the following post Highlighting Strings in JavaFX TextArea
I was trying to achieve the same goal of highlighting individual strings inside a javaFX TextArea until I realised that it pretty much is not possible. So I looked into TextFlow which does allow me to edit individual strings. The problem with TextFlow is that all 200 of the generated words would have to appear at once which is not what I want. With a TextArea not all the text has to be displayed at once.
This is what I have so far just so that you can further get an idea of where I am heading with this.

Unicode character ("\u232B") does not display on button

I'm building the keyboard of a calculator application for Android.
I'm using the unicode but the application did not display the button "erase to left"
static String[][] screen2L ={{"sin","asin","sinh","asinh","sind","asind","\u232B","AC"},
{"cos","acos","cosh","acosh","cosd","acosd","log2","gamma"},
{"tan","atan","tanh","atanh","tand","atand","log10","ln"}};
thanks
Unicode characters are not supported in all fonts. Check here to see the supported fonts for \u232B
Instead of using the character, make an image of the character and set it as the buttons background. A post that can help with that has already been answered here: How to make button with custom background image...
Also, as for using strings in java to print in your GUI, it's better practice to use xml for this. The buttons individual values would be stored to the app instead of having to assign them every time the app is run. I would write out instructions on how this is done, but the android developers guide that can be found here gives much better instructions than I could.

Display emotion icon in Android TextView via Unicode chars or other way

I try to make a chat application for android. Here, I want to show emotion icon in android Text View.
I want to show Emotion Icon like this.
I found one project in github :: https://github.com/sharakova/EmojiTextView. Here is image in drawable but i do not use image. i want to use Unicode chars. So, How can show Emotion icon via Unicode chars.
Some one tell to use Spannable Text but it make my application slow. when use many Emotion icon in chat.
So, Here any way to show Emotion icon in android Text-view?.
Thanks.
1) find UTF-8 character for your emotion
For example smile
http://www.fileformat.info/info/unicode/char/263a/index.htm
2) insert in to text value of "C/C++/Java source code" field
regarding to link above for smile it is "\u263A"
You can use EmojiconTextView or EmojiconEditText from this library : https://github.com/rockerhieu/emojicon

TextView doesn't show text

I'm developing an ebook app for Android. when the text length given in string.xml is very large (around 500 words) it is not shown in the text view.
It took a while for me to figure this out. I have two text views and one is working propoerly as it is a small paragragh with 100 words but the secound TextView is larger and when the event is triggered it shows an empty screen.
Any char limitation in TextView?? wot would be the alternative?? Please help me.
Thanks in advance.
TextView doesn't sound like the correct component for your use. I would imagine you would get much better results using WebView.
You can define your content in HTML files instead of putting that much text into strings.xml.

Scrolling TextView in a ScrollView to a specific substring of text

For starters, I'm a C++/Qt Developer jumping into Android/Java development, so please don't assume I know anything. :) So, I have an application with a TextView contained with in a ScrollView. The text contained in the TextView is the results of a web query from my web server application. Depending on the query, the text can be pretty long. I want to implement a search feature on the text where the user enters some text string to search for, and if the text string is found, the ScrollView will scroll the TextView to ensure the entered substring is visible, and I want the text highlighted. I think I know how to highlight the text substring, I know how to tell the ScrollView to scroll to a specific line number in the TextView, but for the life of me, I can't figure out how to find out what line number to scroll to to guarantee my substring is visible. Ie, I want to query the text view to give me the line number that the substring first occurs at. Eventually, I want to also implement a find next that goes to the next occurrence of the substring. Kind of like the Find feature in Firefox. Any assistance is greatly appreciated. Thanks in advance.
You need to find the position of the substring in the text yourself, e.g. with String.indexOf(). Once you know that position, you can look up the correct line in the TextView using the Layout.getLineForOffset() function:
int offset=myString.indexOf("search string");
int line = myTextView.getLayout().getLineForOffset(offset);

Categories