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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T01:01:12+00:00 2026-05-23T01:01:12+00:00

Hi all i want to move an image using accelerometer values,but m not able

  • 0

Hi all i want to move an image using accelerometer values,but m not able to do it. Can anyone please help me to do this, I have already gone through sample code in android developers site but couldn’t understand properly.

  • 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-05-23T01:01:13+00:00Added an answer on May 23, 2026 at 1:01 am

    To move an image, see how it’s done in this example. Basically, the key is to get a matrix of some kind, and manipulate it based off of some input, in the case of this example, the touch/drag of a user. The below code doesn’t function perfectly, but it shows the key commands and classes required to perform dragging. For more details, see the linked article.

    Matrix matrix = new Matrix();
    savedMatrix.set(matrix);
    matrix.postTranslate(event.getX() - start.x)
    ImageView view = (Some image view here)
    view.setImageMatrix(matrix);
    

    The next part is to somehow use the accelerometer to get input. I’m going to leave it to you how to best put the two together. My source of this information is this article. There are a few basic steps.

    The first step is to register the listener, and is done by this code.

    SensorManager  sensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE);
    Sensor sensor = sensorManager.getSensorList(Sensor.TYPE_ACCELEROMETER).get(0);
    

    The next step is to register a sensor listener. The last bit is to show what the sensor listener looks like. Note that there are 3 outputs of the accelerometer, one for each x, y, and z coordinates.

    @Override
    protected void onResume() {
        super.onResume();
        sensorManager.registerListener(accelerationListener, sensor,
                SensorManager.SENSOR_DELAY_GAME);
    }
    
    @Override
    protected void onStop() {
        sensorManager.unregisterListener(accelerationListener);
        super.onStop();
    }
    
    private SensorEventListener accelerationListener = new SensorEventListener() {
        @Override
        public void onAccuracyChanged(Sensor sensor, int acc) {
        }
    
        @Override
        public void onSensorChanged(SensorEvent event) {
            x = event.values[0];
            y = event.values[1];
            z = event.values[2];
        }
    
    };
    

    Your next step will be to figure out what the x, y, and z values are for your desired application. I suggest you take and log each of these out using a Log.v(TAG,...) statement. Play around with tilting it, and figure out exactly what you want to do. Tune it until it has the right level of sensitivity, by seeing how far off it is from straight up and down, and having some kind of a rate of changing the x and y coordinates of the image. Good luck!

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

Sidebar

Related Questions

I have a directory full of image files. I want to move all the
Possible Duplicate: Can anybody suggest the best image resize script in php? I'm still
i am using the jQuery Plugin Uploadify to upload files, and i store the
hi all im building a menu and im trying to put an hover effect
Need to move the database and log files of JavaDB (derby) db files into
I have designed a file upload form in PHP where it takes 3 pictures
Short question: Given a point P and a line segment L, how do I
I'm trying to wrap my head around Xcode's file organization - or lack there
I am adding a number of large images for a slide-show to a page,
I am looking for a solution (APIs, etc.) for handling a similar experience as

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.