How to make running text in cardview android studio?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP



How to make running text in cardview android studio?



I want to make layout that look like this :



enter image description here



It similar like Card View and Recycler View
but thing that i want to ask is how to make animation like running text inside the Card View. If the text is to long then the text start moving from right to left like running text.
This is how it looks :
enter image description here


Card View


Recycler View


animation


Card View



I already searh in google but I can't find the exactly that i want
Your help will be appreciate,
Thanks




3 Answers
3



You need to add ellipsize property with layout_width of wrap_content or size which you define :


<TextView
android:id="@+id/attatchFilename"
android:layout_width="170dp"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/chooseFile"
android:layout_below="@id/txtMsg"
android:layout_marginTop="10sp"
android:layout_marginLeft="10dp"
android:text=""
android:singleLine="true"
android:focusable="true"
android:ellipsize="marquee"
android:marqueeRepeatLimit="marquee_forever" />



You can do this using android:ellipsize="marquee" In you TextView


android:ellipsize="marquee"


TextView


<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="16dp"
android:layout_marginTop="30dp"
android:padding="16dp"
android:id="@+id/sliding_text_marquee"
android:singleLine="true"
android:ellipsize="marquee"
android:text="Scrolling Text (Marquee) in Android Application"
android:textSize="24sp"
android:textStyle="bold" />



First create this animation in xml:


<translate xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="5000"
android:fromXDelta="100"
android:interpolator="@android:anim/linear_interpolator"
android:repeatCount="infinite"
android:repeatMode="restart"
android:toXDelta="-100" />



Then add the animation to the TextView:


textview.startAnimation(AnimationUtils.loadAnimation(this, R.anim.scroll_animation));






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Firebase Auth - with Email and Password - Check user already registered

Dynamically update html content plain JS

How to determine optimal route across keyboard