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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T14:18:07+00:00 2026-05-31T14:18:07+00:00

I would like to programmatically drag one view and release it on top of

  • 0

I would like to programmatically drag one view and release it on top of another for initialization purposes, is this possible?

EDIT: I’m looking for a way to simulate a drag&drop

  • 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-31T14:18:08+00:00Added an answer on May 31, 2026 at 2:18 pm

    You can remove Views from Layouts and add them to other Layouts (if that’s what you are looking for)

    ViewGroup oldGroup = (ViewGroup) findViewById(R.id.some_layout);
    ViewGroup newGroup = (ViewGroup) findViewById(R.id.some_other_layout);
    
    Button button = (Button) oldGroup.findViewById(R.id.a_button);
    
    oldGroup.removeView(button);
    newGroup.addView(button);
    

    There is no drag&drop animation and it might give strange results but it’s possible.

    A ViewGroup would be a LinearLayout, RelativeLayout and those.


    For simulating Drag&Drop events you could call the onDragListener manually but there is one problem:

    public boolean onDrag(View v, DragEvent event);
    

    expects a DragEvent which has no public constructor so you can only call it with null

    There might be a way to create one via a faked Parcel but that going to be ugly.

    private void initializationTest() {
        DragEvent event = null;
        /* maybe sth like that
        Parcel source = Parcel.obtain();
        source.writeInt(1234);
        event  = DragEvent.CREATOR.createFromParcel(source);
        */
        onDrag(theTargetView, event);
    }
    

    Another possibility is maybe to create touchevents but Idk if that would work. At least the monkey could probably do that.

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

Sidebar

Related Questions

I have a new gesture, (touch, drag onto other, release) which I would like
I drag and drop a Table view on my form application. I would like
I would like to add a UIPageControl item programmatically to my view Controller. The
I would like to be able to programmatically add a viewgroup to another viewgroup.
I would like to programmatically create a gloss effect on an Image, kinda like
I would like to programmatically insert additional rows into a DataGrid (to act as
I would like to programmatically check the value of, and be able to toggle
I would like to programmatically set maxLength property of TextView as I don't want
I have a carbon C++ application and I would like to programmatically do the
I'm writing a simple VS add-in and would like to programmatically invoke the Document

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.