Hello friends today we are creating movement text in android studio. Movement text is text that is horizontal movement on the screen.
And this happens when the text with movement is bigger than the display of the device then there is movement in the text otherwise no movement.
Its code is given below....
activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="vertical"
tools:context=".MainActivity">
<TextView
android:id="@+id/move_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:focusableInTouchMode="true"
android:ellipsize="marquee"
android:marqueeRepeatLimit="marquee_forever"
android:scrollHorizontally="true"
android:singleLine="true"
android:focusable="true"
android:layout_marginBottom="100dp"
android:text="This is text Hello world we are creating for testing"
android:textSize="25sp"/>
</LinearLayout>
MainActivity.java
package com.testproject.testproject;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.TextView;
public class MainActivity extends AppCompatActivity {
TextView movementText;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
movementText=findViewById(R.id.move_text);
movementText.setHorizontallyScrolling(true);
movementText.setSelected(true);
}
}
Below is the screenshot of this app how this app will work.
Thanks you
0 Comments
Please do not enter any spam link in the comment box
Emoji