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

  • Home
  • SEARCH
  • 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 6780327
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T16:29:35+00:00 2026-05-26T16:29:35+00:00

­I’m coding with API 8. I need to get coordinates X and Y from

  • 0

­I’m coding with API 8.
I need to get coordinates X and Y from a View and and set them as the coordinates of a new Button.
I tried different ways but nothing works….

The setX and getX method works only from api level 11, I need a way to do that on API8.

This is my method that allow to create a draggable copy of a button (this copy is an imageview and when I drop it became a new button)

public boolean dragCopy(View view, MotionEvent me, Button bt){ 

        int x,y,w,h,id,t,l;
        int cont=-1;
        int coord[] = new int[2];


        bt2=new Button(this);


        id = bt.getId();
        bt2.setId(id);

        Resources res = getResources();

        cont = FindCont(bt, vector); 

        dr = getLetter(bt, dr,  res, vector, cont);
        w=dr.getIntrinsicWidth();
        h=dr.getIntrinsicHeight();


        if (me.getAction() == MotionEvent.ACTION_DOWN) {
            //clicked on the button. DRAG START
            status = START_DRAGGING;
            image = new ImageView(this);

            //set image drawable
            image.setImageDrawable(dr);
            image.setPadding((int)bt.getLeft(),(int)bt.getTop(), 0, 0);
            layout.addView(image, params);


        }
        if (me.getAction() == MotionEvent.ACTION_UP) {

            //button released. DROP
                        status = STOP_DRAGGING;
            x = (int) me.getRawX();
            y = (int) me.getRawY();

                        //create button compy from image
            bt2.setBackgroundDrawable(dr);
            bt2.setVisibility(View.VISIBLE);

                        //PROBLEMS  
            t= image.getTop();
            l= image.getLeft();
            bt2.setPadding(l, t, 0, 0);
            System.out.println("**************** T: "+t +"--- L: "+l);
            image.setVisibility(View.GONE);
                bt2.setLayoutParams(image.getLayoutParams());

                bt2.setWidth(w);
            bt2.setHeight(h);

            layout.addView(bt2);
                bt2.setDrawingCacheEnabled(true);
            bt2.setOnTouchListener(this);
            bt2.invalidate(); 
            image.invalidate();


        } else if (me.getAction() == MotionEvent.ACTION_MOVE) {

                        //i'm moving the image
            if (status == START_DRAGGING) {

                image.setPadding((int) me.getRawX(), (int) me.getRawY(), 0, 0);
                image.invalidate();

            }
        }
        return false;
    }
  • 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-26T16:29:35+00:00Added an answer on May 26, 2026 at 4:29 pm

    i’ve recreate my drag and drop using andengine. Works great and better than before

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

Sidebar

Related Questions

I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
I am currently running into a problem where an element is coming back from
I want use html5's new tag to play a wav file (currently only supported
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I need to clean up various Word 'smart' characters in user input, including but
I have a text area in my form which accepts all possible characters from
Does anyone know how can I replace this 2 symbol below from the string

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.