Skip to content

Instantly share code, notes, and snippets.

@minibugdev
Last active December 24, 2021 08:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save minibugdev/2228539e3e7734f99e7379d12cac828c to your computer and use it in GitHub Desktop.
Save minibugdev/2228539e3e7734f99e7379d12cac828c to your computer and use it in GitHub Desktop.
Android Marquee Animation
val marquee = AnimationUtils.loadAnimation(context, R.anim.marquee)
textView.startAnimation(marquee)
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="horizontal">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginHorizontal="8dp"
android:src="@drawable/icon" />
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/textView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="none"
android:singleLine="true"
android:text="Text Text Text" />
</FrameLayout>
</LinearLayout>
<!-- anim/marquee.xml -->
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate
android:duration="10000"
android:fromXDelta="100%"
android:repeatCount="infinite"
android:repeatMode="restart"
android:toXDelta="-100%" />
</set>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment