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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T22:54:55+00:00 2026-05-24T22:54:55+00:00

can any one help me how to drag and drop the text view on

  • 0

can any one help me how to drag and drop the text view on entire image view. i found from this drag n drop textview in android here the text view is static, in my app textview and image view’s are dynamically change. `@Override
public boolean onTouchEvent(MotionEvent event) {

  switch (event.getAction()) {
     case MotionEvent.ACTION_DOWN:
         // Remember our initial down event location.
         startX = event.getRawX();
         startY = event.getRawY();
         break;
    case MotionEvent.ACTION_MOVE:
         float x = event.getRawX();
         float y = event.getRawY();
        // Calculate move update. This will happen many times
        // during the course of a single movement gesture.
        scrollByX = x - startX; //move update x increment
        scrollByY = y - startY; //move update y increment
        startX = x; //reset initial values to latest
        startY = y;
        invalidate(); //force a redraw
        break;
      }
   return true; //done with this event so consume it
 } 

i wright this code, but it’s not working 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-24T22:54:56+00:00Added an answer on May 24, 2026 at 10:54 pm

    You can always change the image and text of existing view programatically using setText sort of methods.

    There are many drag and drop tutrials if you google it. strongly suggest you try them out.
    Basically what you do is implement a OnTouchListener on the TextView like

    textview.setOntouchListener(listen);

    OnTouchListener onThumbTouch = new OnTouchListener()
        {
            @Override
            public boolean onTouch(View v, MotionEvent event) 
            {   
                switch(v.getId())
                {
                    case R.id.slider_thumb_id:
                    {
                        switch(event.getAction())
                        {
                            case MotionEvent.ACTION_MOVE:
                            {                           
    
    
                            }
                            case MotionEvent.ACTION_UP:
                            {                           
    
                            }
                        }
                        break;
                    }
                }
                return true;
            }
        };
    

    Here from the event attribute you get the value of x and y and the touch event and
    use that to alter the position of the textview. I did it by add add/subtracting the margin values.

    EDIT:
    This is what I did to update the position of my view
    Look event.getRawY(); is going to give you the distance from the parent view. So if I get event.getRawY() = 50. I know I need the text view to be 50 pixels from the top.

    LinearLayout.LayoutParams iconParams = (LinearLayout.LayoutParams) 
       v.getLayoutParams();
    iconParams.topMargin = 50;
    v.setLayoutParams(iconParams);
    

    So now the view that i selected is 50 px from the top of the parent view.

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

Sidebar

Related Questions

can any one help me with code that subtract 1 from a digit stored
Can Any one help me reading this XML and Looping through <MedicationDispensed> I get
Can any one please help me solve this. I am resizing some flash object/embed
can any one help me how to add dynamic tablelayout into static main.xml layout,
can any one help me in creating a regular expression for password validation. The
Can any one help me how to sort rows by relevance for the following
I am new in Pocket PC and Smart phone. so can any one help
I want to bound JVM with a fixed memory limit. Can any one help
Can any one of you help me in converting an windows dll file in
Can anyone help me make sense of this error message? I wrote a drag

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.