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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T08:29:48+00:00 2026-06-08T08:29:48+00:00

Its quite simple thing which i am doing, i have done it before but

  • 0

Its quite simple thing which i am doing, i have done it before but now its not running as i expected. Anyways Let me explain briefly what i am trying to do and what i am getting::

Scenario::
I have a RelativeLayout in which an ImageView is placed, Now i set the touchlistener like this: imageview.setOnTouchListener(this);

It asked me to override the onTouch(View v,MotionEvent event) function which i did…
and in the Action_Move i get the x and y and add them to left and top margins, in this way I am moving my image.

Weird Problem:
My ImageView is moving but with a very noticeable shake, like if i am moving in right direction, ImageView will go to right side but on its way it comes back to left side so that it looks like image is not stable, its vibrating.. something like that.. I am giving the x and y which i get during log… hope this gives you the idea.

ACTION_DOWN[#0(pid 0)=160,233]  Going right..
ACTION_MOVE[#0(pid 0)=160,233]  ////
ACTION_MOVE[#0(pid 0)=160,233]  //
ACTION_MOVE[#0(pid 0)=174,231]  //
ACTION_MOVE[#0(pid 0)=176,233]  //
ACTION_MOVE[#0(pid 0)=196,232]  //
ACTION_MOVE[#0(pid 0)=152,232]  // suddenly i got 152 as location for x... image comes     back
ACTION_MOVE[#0(pid 0)=167,232]  // again started to go right
ACTION_MOVE[#0(pid 0)=180,233]  // going right
ACTION_MOVE[#0(pid 0)=173,233]  // again comes a little back
ACTION_MOVE[#0(pid 0)=187,232]  // same thing goes till end..
ACTION_MOVE[#0(pid 0)=159,232]
ACTION_MOVE[#0(pid 0)=174,231]
ACTION_MOVE[#0(pid 0)=177,233]
ACTION_MOVE[#0(pid 0)=189,231]
ACTION_MOVE[#0(pid 0)=155,232]
ACTION_MOVE[#0(pid 0)=171,231]
ACTION_MOVE[#0(pid 0)=183,230]
ACTION_MOVE[#0(pid 0)=161,234]
ACTION_MOVE[#0(pid 0)=171,233]
ACTION_MOVE[#0(pid 0)=174,230]
ACTION_MOVE[#0(pid 0)=183,230]
ACTION_MOVE[#0(pid 0)=162,234]
ACTION_MOVE[#0(pid 0)=170,233]
ACTION_MOVE[#0(pid 0)=176,233]
ACTION_MOVE[#0(pid 0)=165,233]
ACTION_MOVE[#0(pid 0)=175,232]
ACTION_MOVE[#0(pid 0)=163,233]
ACTION_MOVE[#0(pid 0)=171,233]
ACTION_MOVE[#0(pid 0)=167,233]
ACTION_MOVE[#0(pid 0)=172,232]
ACTION_MOVE[#0(pid 0)=178,232]
ACTION_MOVE[#0(pid 0)=158,234]
ACTION_MOVE[#0(pid 0)=170,234]
ACTION_MOVE[#0(pid 0)=170,232]
ACTION_MOVE[#0(pid 0)=177,231]
ACTION_MOVE[#0(pid 0)=157,234]
ACTION_MOVE[#0(pid 0)=160,234]
ACTION_MOVE[#0(pid 0)=169,232]
ACTION_MOVE[#0(pid 0)=165,233]
ACTION_MOVE[#0(pid 0)=167,233]
ACTION_MOVE[#0(pid 0)=159,233]
ACTION_UP  [#0(pid 0)=161,233]

XML code for RelativeLayout:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" 
    android:background="#99000000">

    <ImageView
        android:id="@+id/imageview"
        android:layout_width="400dp"
        android:layout_height="400dp"
        android:layout_marginLeft="100dp"
        android:layout_marginTop="100dp"
        android:scaleType="matrix" />
</RelativeLayout>

So, this is the max, i could explain my question, still if you need anything, let me know.

Update::
Code for moving the ImageView in its Container i.e RelativeLayout:

case MotionEvent.ACTION_MOVE:
            LayoutParams params = (LayoutParams) imageview.getLayoutParams();

            params.leftMargin = params.leftMargin + x;
            params.topMargin = params.topMargin + y;

            imageview.setLayoutParams(params);
            break;
  • 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-08T08:29:50+00:00Added an answer on June 8, 2026 at 8:29 am

    The X and Y variables in onTouch are the X and Y relative to the View which has the onTouchListener attached. so 10, 10 would be from the top left of your ImageView not of the RelativeLayout.

    If you use these values to move your ImageView then you will naturally get shaky behavior, each move action will also fire a slightly different OnTouchEvent causing another move action – this recursion gives you a “vibrating” effect.

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

Sidebar

Related Questions

My problem seems to be quite simple, but it's not working the intuitive way.
I have recently started diving into Haskell. Its quite interesting, but the definition of
I guess this is a quite simple (read: very simple) question, but I have
I have a C++ program. It's quite simple - shows an image (splash screen)
I'm aware it's a quite simple question but I'm a newbie to C#, ASP.NET
I'm learning JQuery and have found the factory function $() with its selectors quite
I am building a 'tag' system. I quoted it because its not quite a
I'm trying to accomplish a fairly simple task for my website, but Im not
I've been doing .NET and C# programming for quite some time, but this is
my problem is quite simple, but very important in general - I think. I

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.