'How to set the part of the text view between @ and alphanumeric (same as telegram user) is clickable in android java?
I want to convert the part of a string (textview) that contains the username to clickable and after the user clicks, move it to the same user's profile page (like messengers like Telegram) For example : My username in Telegram is @Khapez
I'm going to make Khapez clickable
Thank you all
Solution 1:[1]
Solution 2:[2]
you have to use Position: "absolute", with suitable value for bottom,top,left,right to keep the username View next to @ in different View
<View style={{width: "80%", height: 100}}>
<View style={{width: 50, height: 50}}>
<Text>@</Text>
<View>
<TouchableOpacity style={{position: "absolute", top: 0, left: 50}}>
<Text>@</Text>
<TouchableOpacity>
<View>
tweak the top and left value as per position, only after padding, margin etc done and set to View that contains @
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Sambhav. K |
Solution 2 |