Android TextView Horizontal scrolling (marquee effect)

Source: Internet
Author: User

Android TextView When the text is a long time to expect it to scroll horizontally, the following is a pro-test feasible method.


1. Custom TextView, override the IsFocused () method to return True to have the custom TextView always in the get focus state.

Package Com.example.shen.marqueedemo;import Android.content.context;import Android.util.attributeset;import android.widget.textview;/** * Created by Shen on 2015/8/19. */public class Marqueetextview extends TextView {public    Marqueetextview (context context) {        super (context);    } Public    Marqueetextview (context context, AttributeSet Attrs) {        Super (context, attrs);    }    Public Marqueetextview (context context, AttributeSet attrs, int defstyleattr) {        Super (context, attrs, defstyleattr) ;    }    @Override Public    Boolean isFocused () {        return true;    }}
2. Layout files

Android:sigleline= "true"//single line

Android:ellipsize= "marquee"//display in the way of a marquee (animation lateral movement)

android:marqueerepeatlimit= "Marquee_forever"//Keep rolling

<relativelayout xmlns:android= "http://schemas.android.com/apk/res/android"    android:layout_width= "Match_ Parent "    android:layout_height=" match_parent ">    <com.example.shen.marqueedemo.marqueetextview        Android:layout_width= "200DP"        android:layout_height= "wrap_content"        android:text= "hello_world! hello_ world! hello_world! "        android:layout_centerinparent=" true "        android:ellipsize=" marquee "        android:singleline=" true "        android:marqueerepeatlimit= "Marquee_forever"/></relativelayout>




Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Android TextView Horizontal scrolling (marquee effect)

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.