This article has shared the horizontal touch sliding effect of single line text, and realized the horizontal sliding effect of textview single length text through EditText.
The next one again for you to introduce multiple lines of text folding expansion effect, custom layout view to achieve multiline text folding and expansion.
1. Original intention
The recent application of the time useful to TextView single president text, when the text content is too long to achieve touch horizontal sliding effect. Looking for a lot of online, did not see an effective solution.
Among them, see the most common and most clumsy drop using rewrite TextView and inherit to implement touch and gesture gestures. Personally feel very troublesome.
It was then recalled that the simplest solution was:
It would be nice to use the edittext directly. Because EditText needs to edit and move the cursor, it can slide horizontally. So we just need to set it to a transparent background and not get focus.
Effect Chart:
2. Concrete implementation
Define the EditText and set the background transparent to not get focus.
Android:background= "@android: Color/transparent"
Android:focusable= "false"
(Note: You cannot use editable= "false" because you cannot edit the slide.) By using the focusable= "false" is also not editable and can be sliding at the same time
3. Supplementing
To add, to hide the cursor, use only the settings
Android:cursorvisible= "false"//hidden
or
Setcursorvisible (FALSE);
code example:
<edittext
android:id= "@+id/tt"
android:layout_width= "0dip"
android:layout_height= "Wrap_content"
android:layout_weight= "1"
android:layout_margin= "15dip"
android:background= "@android: color/ Transparent "
android:focusable=" false "
android:singleline=" true "
android:cursorvisible=" false "
android:text= "Simple implementation of TextView single line text horizontal touch sliding effect. Simple realization TextView Single text horizontal touch sliding effect. Simple realization of TextView single line text horizontal touch sliding effect "
android:textcolor=" #000 "
android:textsize=" 20dip "/>
Attached download address: Http://xiazai.jb51.net/201610/yuanma/Androidtouchmove (jb51.net). rar
The above is the entire content of this article, I hope to help you learn, but also hope that we support the cloud habitat community.