Android : TextView horizontally scrolling

android textview scroll horizontally programmatically
android textview scroll vertically
android textview scroll vertically automatically
horizontal recyclerview android
marquee textview android
android textview horizontal scroll not working
android textview scroll to bottom
scroll inside textview android

I want to create a TextView that scroll from right to left and then disappears from left and reappears from right again. I can use animation ?? Thanks

I believe you want your text view to marquee. If so, this is how I did it:

In the XML. Set the following attributes for the TextView:

android:singleLine="true"
android:ellipsize="marquee"
android:marqueeRepeatLimit="marquee_forever"
android:focusable="false"
android:scrollHorizontally="true"

If your TextView is within a RelativeLayout, the width or height will have to be static (i.e. 32dp). If you need dynamic, place the TextView in another View within the RelativeLayout.

In onCreate(), you need to make the TextView selected:

myTextView.setSelected(true);

Original Answer

Android automatic horizontally scrolling TextView, android:imeOptions="actionSend" only work in single. TextView tv = (TextView) findViewById(R.id.editText); if (tv != null) { tv.setHorizontallyScrolling(false); tv. Create text in textView in horizontal scroll bar format using HorizontalScrollView example tutorial. Creating textView with horizontally text format with horizontal scrollview is very easy with the use of HorizontalScrollView widget. So here is the complete step by step tutorial for Scroll textview text horizontally in android using ScrollView.

I use this code to animate my textView in recyclerView. (this code can use any whree)

in xml

<HorizontalScrollView
                android:id="@+id/scrollViewTxtAppsEn"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:focusable="true"
                android:scrollbars="none"
                android:visibility="visible"
                >

                <TextView
                    android:id="@+id/txtAppsEn"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:paddingTop="4dp"
                    android:paddingBottom="8dp"
                    android:clickable="true"
                    android:focusable="true"
                    android:gravity="center"
                    android:maxLines="1"
                    android:scrollHorizontally="true"
                    android:text=""
                    android:textColor="@color/textColorDark"
                    android:textSize="9sp"
                    />
            </HorizontalScrollView>

In adapter

 @Override
  public void onViewAttachedToWindow(@NonNull ViewHolder holder) {
    handelAnimationTextView(holder.txtAppsEn, holder.scrollViewTxtAppsEn, true);
    super.onViewAttachedToWindow(holder);
  }

private void handelAnimationTextView(TextView textView, HorizontalScrollView scrollViewTextView, boolean isRightToLeft) {
    textView.post(new Runnable() {
      @Override
      public void run() {
        if (canScroll(scrollViewTextView)) {
          if (isRightToLeft) {
            textView.startAnimation((Animation) AnimationUtils.loadAnimation(G.currentActivity, R.anim.text_view_anim_right_to_left));
          } else {
            textView.startAnimation((Animation) AnimationUtils.loadAnimation(G.currentActivity, R.anim.text_view_anim_left_to_right));
          }
        }
      }
    });
  }

  private boolean canScroll(HorizontalScrollView horizontalScrollView) {
    View child = (View) horizontalScrollView.getChildAt(0);
    if (child != null) {
      int childWidth = (child).getWidth();
      return horizontalScrollView.getWidth() < childWidth + horizontalScrollView.getPaddingLeft() + horizontalScrollView.getPaddingRight();
    }
    return false;

  }

text_view_anim_left_to_right.xml

<?xml version="1.0" encoding="utf-8"?>
<translate xmlns:android="http://schemas.android.com/apk/res/android"
           android:duration="6000"
           android:fromXDelta="-100%"
           android:interpolator="@android:anim/linear_interpolator"
           android:repeatCount="infinite"
           android:repeatMode="restart"
           android:toXDelta="100%"/>

text_view_anim_right_to_left.xml

<?xml version="1.0" encoding="utf-8"?>
<translate xmlns:android="http://schemas.android.com/apk/res/android"
           android:duration="6000"
           android:fromXDelta="100%"
           android:interpolator="@android:anim/linear_interpolator"
           android:repeatCount="infinite"
           android:repeatMode="restart"
           android:toXDelta="-100%"/>

Hope I have helped

android.widget.TextView.setHorizontallyScrolling java code , Auto scrolling (horizontal running) TextView This video show how it tested on Android Duration: 1:14 Posted: Aug 29, 2016 Create TextView with scrolling feature to insert multiple lines of text inside textview on single activity. Making textview text is scrollable is very easy with the use of android:scrollbars=”vertical” attribute inside textview text widget this attribute will enable scrollbar display as vertically format and now we have to add setMovementMethod(new ScrollingMovementMethod()); on textview

Does this help? Found it here

<LinearLayout android:orientation="vertical">
<HorizontalScrollView>
    <LinearLayout android:orientation="horizonal">
        <Image1 />
        <Image2 />
        <Image3 />
        <Image4 />
        <Image5 />
    </LinearLayout>
</HorizontalScrollView>
<LinearLayout android:orientation="horizonal">
    <Button1 android:layout_weight="1" />
    <Button2 android:layout_weight="1" />
    <Button3 android:layout_weight="1" />
    <Button4 android:layout_weight="1" />
</LinearLayout >

Auto scrolling (horizontal running) TextView, Take a Android TextView horizontal scrolling automatically. Test on Android emulator running Duration: 1:14 Posted: Aug 29, 2016 The code below creates an automatic horizontal scrolling textview: While adding TextView to xml use <TextView android:maxLines="1" android:ellipsize="marquee" android:scrollHorizontally="true"/> Set the following properties of TextView in onCreate() tv.setSelected(true); tv.setHorizontallyScrolling(true);

If you want scroll text while control is focused use

<TextView ... android:ellipsize="marquee" android:singleLine="true"/>

Otherwise you should implement this yourself:

  1. Using timer (or Handler) and setting offset to TextView
  2. Stole this
  3. Or maybe try this

Auto scrolling (horizontal running) TextView, How to Add Multiple Images to Horizontal Scroll View in Android - Duration: 6:54. ID 29,534 Duration: 4:44 Posted: Nov 6, 2016 I've been looking around for quite some time now, and I can't get a straight answer for my question. It's quite simple: How can I get a nice scrolling text just like the long app names in the Market

Android Scrollable TextView, two together is possible to achieve the effect of a text view within a larger container. HorizontalScrollView only supports horizontal scrolling. This example demonstrates how do I create a scrollable textView in android app. Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.

HorizontalScrollView, Android automatic horizontally scrolling TextView. I am trying to implement a single-line text view that will scroll automatically. But I unfortunatly cannot get it to � In android, ScrollView supports only vertical scrolling. In case, if we want to implement horizontal scrolling, then we need to use a HorizontalScrollView component. The android ScrollView is having a property called android:fillViewport, which is used to define whether the ScrollView should stretch it’s content to fill the viewport or not.

Android automatic horizontally scrolling TextView, setMovementMethod(new ScrollingMovementMethod());. Now the TextView will automatically scroll vertically. Horizontally Scrolling. In other cases, we want� Note that a TextView doesn't require a ScrollView and if you just need a scrolling TextView simply set the scrollbars property and apply the correct MovementMethod: <TextView android:id= "@+id/tv_long" android:layout_width= "wrap_content" android:layout_height= "match_parent" android:scrollbars = "vertical" android:text= "@string/really_long

Comments
  • no, I want that the textview automatically to move right to left