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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T04:31:53+00:00 2026-05-27T04:31:53+00:00

I have an app filled with custom buttons for Android. I would like to

  • 0

I have an app filled with custom buttons for Android. I would like to allow user to rearrange these buttons like image buttons of Home or Application panel.

I researched on this and found out that I can use drag & drop functionality to interact with user’s motion. But in my case parent layout can be different. OnMove or OnDrop event, I need to actually move that button in that corresponding layout.

So question is how I can find a layout that contains coordinate x & y and put the button in it.

@Override
public boolean onTouchEvent(MotionEvent event) {


    switch (event.getAction()) {
    case MotionEvent.ACTION_DOWN:
        status = START_DRAGGING;
        break;
    case MotionEvent.ACTION_UP:
        status = STOP_DRAGGING;
        break;
    case MotionEvent.ACTION_MOVE:
        if(status == START_DRAGGING){
            //parentLayout.setPadding((int)event.getRawX(), 0,0,0);
            //**What to do here**
            parentLayout.invalidate();
        }                           
        break;

    }

    return true;
}
  • 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-27T04:31:54+00:00Added an answer on May 27, 2026 at 4:31 am

    You can loop through all the controls in the parent container and compare each child’s bounds with the current X, Y. You can get a views bounds by calling this:

    View.getHitRect()

    So something like this:

    for(View v : parent.children())
    {
        // only checking ViewGroups (layout) obviously you can change
        // this to suit your needs
        if(!(v instanceof ViewGroup))
            continue;
    
        if(v.getHitRect().contains(x, y))
            return v;
    }
    

    This is just Psuedo-code and will need to be adapted for whatever you use is (i.e. adding recursion for nested controls).

    Hope that helps.

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

Sidebar

Related Questions

I have implemented a test app with Android's In-App Billing. I have filled in
I have a iframe application, in that app i put a fb like plugin.
In my qt app I have this object, filled before setting up my QTreeWidget's
I have a working UITableView filled with some options for my app, and i
I have app.config in m win application, and loggingConfiguration section (enterprise library 4.1). I
In my app I have a tableView filled with contents from a server. To
I have a Django app that allows the user to create variables and name
i have implemented the in app purchase in my application and added few in
Let's say I have and custom STS which authenticates users of a web app.
I have an OSX core data app (non-document based) with several tables. I'd like

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.