0

I'm using this textview and it works fine. but current marquee is right to left. I want to change it from left to right . how can I change it ?

            <TextView
                android:id="@+id/txt_view_clerk"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_centerVertical="true"
                android:layout_marginRight="4dp"
                android:text="سنکیبنسکین مسنبک سنیکبم نککسن  کمن کمینسبکم نکن کنسبک سکیم بنکسمنیب کمسنی ب"
                android:lines="1"
                android:ellipsize="marquee"
                android:fadingEdge="horizontal"
                android:marqueeRepeatLimit="marquee_forever"
                android:singleLine="true"
                android:focusable="true"
                android:focusableInTouchMode="true"
                android:freezesText="true"
                android:gravity="right"
                android:scrollHorizontally="true"
                android:layout_toLeftOf="@+id/img_view_clerk"/>
S.M_Emamian
  • 17,005
  • 37
  • 135
  • 254
  • Check out this repository: [CustomViews](https://github.com/activesince93/CustomViews). Use `ScrollingTextView` for marquee effect. – activesince93 Nov 20 '15 at 09:45
  • Arabic font android will make it itself... – droida Nov 20 '15 at 10:01
  • 1
    Possible duplicate of [How to reverse the direction of marquee of a TextView](http://stackoverflow.com/questions/6704080/how-to-reverse-the-direction-of-marquee-of-a-textview) – Zahan Safallwa Nov 20 '15 at 10:01

3 Answers3

2

You can better use animation for that.

Animation animationToRight = new TranslateAnimation(-400,400, 0, 0);
    Animation animationToLeft = new TranslateAnimation(400, -400, 0, 0);

animationToLeft.setDuration(12000); 
    animationToLeft.setRepeatMode(Animation.RESTART);
    animationToLeft.setRepeatCount(Animation.INFINITE);
TextView textView= (TextView) findViewById(R.id.textViewMarqToRight);

    textViewMarqToLeft.setAnimation(animationToLeft);

You can chose any one animation and appply it to your desired view.

AnswerDroid
  • 1,873
  • 2
  • 33
  • 52
2

Use below xml code in new folder under res :

<?xml version="1.0" encoding="utf-8"?>
<set
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:interpolator="@android:anim/linear_interpolator"
    android:fillAfter="true">

   <translate
        android:fromXDelta="-3%p"
        android:toXDelta="3%p"
        android:duration="1200" />
</set>

And, just add this to your textview :

yourTextView.startAnimation(AnimationUtils.loadAnimation(activity, R.newfolder.move));
vasanth
  • 395
  • 1
  • 3
  • 22
0

Check out BidiFormatter, added recently in the Compatibility Package and native rtl support blog

You can then set the marquee programmatically as following

if (bidiFormatter.isRtlContext()) {
   txt_view_clerk.setEllipsize(TextUtils.TruncateAt.BEGIN);
} else {
   txt_view_clerk.setEllipsize(TextUtils.TruncateAt.END);
}

Alternatively you can try

android:textDirection="anyRtl" in you xml.

Aditya Vyas-Lakhan
  • 13,409
  • 16
  • 61
  • 96
Abhishek Kumar
  • 378
  • 2
  • 8