Android UI enables single text horizontal touch sliding effect _android

Source: Internet
Author: User

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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.