Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7991781
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T13:23:24+00:00 2026-06-04T13:23:24+00:00

I’m trying to create moving text.I have crated surface view and thread for looping

  • 0

I’m trying to create moving text.I have crated surface view and thread for looping it.but it not show me a moving motion but draw that text each after like * ** * * in infinite.

But what I need was move that this point to that** -> ** got it?

this is my code

package com.CurvePackage.Curve;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.view.MotionEvent;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
import android.widget.Toast;

public class Origin extends SurfaceView implements SurfaceHolder.Callback {
    Context context1;
    private MainThread thread;
    private int x=0;
    private int y=0;


    public Origin(Context context) {
        super(context);
        // TODO Auto-generated constructor stub
        setWillNotDraw(false);
        context1 = context;
        getHolder().addCallback(this);
        thread = new MainThread(getHolder(), this);

        setFocusable(true);

    }

    @Override
    protected void onDraw(Canvas canvas) {
        // TODO Auto-generated method stub
        super.onDraw(canvas);
        Paint paint = new Paint();
        paint.setTextSize(23);
        paint.setFakeBoldText(true);
        paint.setColor(Color.YELLOW);
        // int score=(10-sprites.size()*100);
        x=x+20;
        y=y+20;
        canvas.drawText("ewqewqe", x, y, paint);
    }

    @Override
    public boolean onTouchEvent(MotionEvent event) {
        // TODO Auto-generated method stub
        return super.onTouchEvent(event);
        // Toast.makeText(getba, "Replay clicked!", Toast.LENGTH_SHORT).show();
    }

    public void surfaceChanged(SurfaceHolder arg0, int arg1, int arg2, int arg3) {
        // TODO Auto-generated method stub

    }

    public void surfaceCreated(SurfaceHolder holder) {
        // TODO Auto-generated method stub
        thread.setRunning(true);
        thread.start();

    }

    public void surfaceDestroyed(SurfaceHolder holder) {
        thread.setRunning(false);
        // TODO Auto-generated method stub
//      boolean retry = true;
//      while (retry) {
//          try {
//              thread.join();
//              retry = false;
//          } catch (InterruptedException e) {
//              // try again shutting down the thread
//          }
//      }

    }
}

Main Thread

package com.CurvePackage.Curve;

import android.graphics.Canvas;
import android.view.SurfaceHolder;

public class MainThread extends Thread {

    // flag to hold game state
    private boolean running;
    private SurfaceHolder surfaceHolder;
    private Origin origin;
     static final long FPS = 15;

    public void setRunning(boolean running) {
        this.running = running;
    }

    @Override
    public void run() {

        long ticksPS = 1000 / FPS;
        long startTime;
        long sleepTime;

        while (running) {
            Canvas c = null;
            startTime = System.currentTimeMillis();
            try {
                   c = origin.getHolder().lockCanvas();
                   synchronized (origin.getHolder()) {
                       origin.onDraw(c);
                   }
            } finally {
                   if (c != null) {
                       origin.getHolder().unlockCanvasAndPost(c);
                   }
            }


            sleepTime = ticksPS-(System.currentTimeMillis() - startTime);
            try {
                   if (sleepTime > 0)
                          sleep(sleepTime);
                   else
                          sleep(10);
            } catch (Exception e) {}
        }

    }

    public MainThread(SurfaceHolder surfaceHolder, Origin origin) {
        super();
        this.surfaceHolder = surfaceHolder;
        this.origin = origin;
    }

}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T13:23:26+00:00Added an answer on June 4, 2026 at 1:23 pm

    You need to paint the entire background in your onDraw method, before you paint your text.

    Paint p2 = new Paint();
    p2.setStyle(Style.FILL);
    canvas.drawRect(0, 0, screenWidth, screenHeight, p2);
    //draw text here
    

    This will completely paint over the text from the previous time the canvas was drawn, and will remove this dragging effect.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have a French site that I want to parse, but am running into
I have a text area in my form which accepts all possible characters from
I have an MVC Razor view @{ ViewBag.Title = Index; var c = (char)146;
I'm trying to create an if statement in PHP that prevents a single post
I have a reasonable size flat file database of text documents mostly saved in
I am trying to loop through a bunch of documents I have to put
I have a bunch of posts stored in text files formatted in yaml/textile (from
I am trying to understand how to use SyndicationItem to display feed which is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.