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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T06:37:49+00:00 2026-06-01T06:37:49+00:00

I need to create a compass on an app i am working on. So

  • 0

I need to create a compass on an app i am working on. So i tried to create a new view called CompassView which basically extends imageview, shows a bitmap that has east west north south pointed on it, uses sensors to find the degrees the phone is pointed at, and rotate the image accordingly so that it would create an actual compass. But the problem is if i try to rotate the image to some angles like 45 degrees, it shrinks down. Here are some images to explain it better.

This is normal

This is shrinked

As you can see, the second image is shrinked down when i try to rotate around 45. What i want it to do is this:
this

Here is the code i am currently using:

        Bitmap bMap = BitmapFactory.decodeResource(getResources(),
                R.drawable.compass);
        Matrix xMatrix = new Matrix();
        xMatrix.reset();
        xMatrix.postRotate(360-mValue, 75, 75); //This is 75 because 150 is the image width
        Bitmap bMapRotate = Bitmap.createBitmap(bMap, 0, 0,
                bMap.getWidth(), bMap.getHeight(), xMatrix, true);
        setImageBitmap(bMapRotate);

Any help would be appreciated. THanks

EDIT: (SOLUTION)
I finally got it working thanks to the accepted answer. Here is the code i am using for anyone who wants to know how it worked:

RotateAnimation rAnimAntiClockWise = new RotateAnimation(
                    360 - mValue, 360 - event.values[0],
                    Animation.RELATIVE_TO_SELF, 0.5f,
                    Animation.RELATIVE_TO_SELF, 0.5f);
//mValue is the angle in degrees and i subtracted it from 360 to make it anticlockwise, and event.values[0] is the same thing as mValue
rAnimAntiClockWise.setFillAfter(true);
rAnimAntiClockWise.setInterpolator(new LinearInterpolator());
rAnimAntiClockWise.setDuration(0);
startAnimation(rAnimAntiClockWise);
  • 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-01T06:37:51+00:00Added an answer on June 1, 2026 at 6:37 am

    You can use a alternative trick which will work like same as rotate and doesn’t resize the image. I actually rotate the image with 45 degree angle and remain changes after animation.

    rAnimAntiClockWise = new RotateAnimation(0.0f, 45.0f,
                    Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF,
                    0.5f);
            rAnimAntiClockWise.setFillAfter(true);
            rAnimAntiClockWise.setInterpolator(new LinearInterpolator());       
                bitmap = BitmapFactory.decodeResource(getResources(),
                        R.drawable.rotate);     
            rAnimAntiClockWise.setDuration(100);
            img_rotate.startAnimation(rAnimAntiClockWise);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Need to create a custom DNS name server using C which will check against
I need create three random links to other posts, in my post view function.
I want to display the compass(Image View) on device at a specific location.I tried
I want add new user from another script and I need create password for
I need create WebView which can load a page from Youtube. I don't want
I need create custom dialog and put JPanel into it. Is it possible?
i need create an email list sending to many emails. what is best solution
I need create clone repository. but I do not know where can I get
I need create a document word with Java. And I ask, how can I
i need create a variable with parent subclass. Example: Parent Class <?php class parentClass

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.