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 5969245
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T20:12:10+00:00 2026-05-22T20:12:10+00:00

I have the following class: public class MainActivity extends Activity { /** Called when

  • 0

I have the following class:

public class MainActivity extends Activity {
/** Called when the activity is first created. */

String value = "0";

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
            WindowManager.LayoutParams.FLAG_FULLSCREEN);

        setContentView(new GaugeAnimation(this));

       }

     }

My GuageAnimation class is as follows:

public class GaugeAnimation extends View{

private Path p;
private Paint cPaint = new Paint();
private int width = 200;
private int angleStart = 135;
private int sweep = 90;
private int value=0;

Bitmap bottom = BitmapFactory.decodeResource(getResources(), R.drawable.dashboard_rpm_bottom);
Bitmap top= BitmapFactory.decodeResource(getResources(), R.drawable.dashboard_rpm_active);

public GaugeAnimation(Context context){
    super (context);

        //Arc Equations & etc.... 

}

@Override
public void onDraw(Canvas c){


    Paint paint = new Paint();
    paint.setFilterBitmap(false);
    paint.setColor(Color.BLUE);
    c.translate(55,320);       

    //Draw bottom image on canvas

  c.save();

    p.addArc(new RectF(0,0,width,width), angleStart, sweep);
    p.lineTo(width/2, width/2);


    c.clipPath(p);

    //draw Image on top

    c.restore();

   invalidate()

}


 }

so basically this crops a circular image one piece at a time based on arc equations. I want to show an animation like the circle’s pieces all being filled in (so showing each clipped path which demonstrates a circle being built). So i was thinking of doing a for loop like:

 for (int i=0; i<100; i++) {
   sweep=i;
   p.addArc(new RectF(0,0,width,width), angleStart, sweep);
    p.lineTo(width/2, width/2);

    c.clipPath(p);
        invalidate();
 }

but this doesn’t work it just draws the end result when i=100, anyone have an idea as to how i can do this?

  • 1 1 Answer
  • 1 View
  • 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-05-22T20:12:10+00:00Added an answer on May 22, 2026 at 8:12 pm

    Currently your loop is performed on the main thread and keeps it busy, so it will not actually update the UI until you finish.

    You should do the loop in a background thread (using Timer or AsyncTask) and perform the paint on main thread. Note that without a short sleep, it will probably would look like an animation too much, it will be pretty fast.

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

Sidebar

Related Questions

I have the following class: public abstract class AbstractParent { static String method() {
I have a public class FriendMaps extends MapActivity that gets called from a menu
I have the following class: public class Topic { public string Topic { get;
I have the following class public class Car { public Name {get; set;} }
Suppose I have the following class: public class TestBase { public bool runMethod1 {
Let's say I have the following class: public class Test<E> { public boolean sameClassAs(Object
I have the following class objects: public class VacancyCategory { public int ID {
Let's have the following class hierarchy: public class ParentClass implements SomeInterface { } public
Let's say I have the following class structure: class Car; class FooCar : public
I have the following situation: class A { public: A(int whichFoo); int foo1(); int

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.