OK At first we will create the XML that contains a TextView.


<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_height="match_parent" >

    android:text="Really Long Scrolling Text Goes Here.... ..... ............ .... ...."
    android:layout_height="wrap_content" />

Now the java code

package com.example.marqueetext;

import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.widget.TextView;

public class Marqueetext extends Activity {

    public void onCreate(Bundle savedInstanceState) {
        TextView tv = (TextView) this.findViewById(R.id.TextView03);  
        tv.setSelected(true);  // Set focus to the textview

    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.marqueetext, menu);
        return true;

Note : The XMl alone will not create the marquee. For that the most important thing is to do this in java code.

 tv.setSelected(true);  // Set focus to the textview

Now run the project and see the result.





  1. unkwn March 29, 2014 at 12:25 pm

    bhenchod fudu bnaya sala ..ruk krke dekh only text stay hota hai..marquee nhi bc..

  2. Iram June 30, 2014 at 11:40 am

    Thanks for sharing 🙂

  3. sai January 2, 2015 at 4:27 am

    getMenuInflater().inflate(R.menu.marqueetext, menu);
    In the above line i’m getting an error and that’s it…….
    regarding that the code was very good and easily understandable…..

    • James June 26, 2015 at 9:21 am

      what is the error you are getting? Is it crashing the application?

  4. Nishu July 11, 2015 at 11:04 am

    how can i make marque to scroll only once and only till the end of text???

    • James July 14, 2015 at 9:54 am

      Try changing “android:marqueeRepeatLimit”

  5. vinod July 23, 2015 at 4:58 pm

    The code was easily understandable but i want to add more than one options in single marquee….can u plss suggest the code

    • James August 29, 2015 at 4:09 pm

      what do you mean by “more than one options”?

  6. AKHTAR ALI SIDDIQUI June 16, 2017 at 5:21 am

    its really good site for understanding the android code


Leave a Reply

Your email address will not be published. Required fields are marked *




Theme by HermesThemes

Copyright © 2018 CoderzHeaven. All Rights Reserved

Please wait...

Subscribe to our newsletter

Want to be notified when our article is published? Enter your email address and name below to be the first to know.