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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T00:30:03+00:00 2026-06-05T00:30:03+00:00

I have layout with 5 different child views, Child views are relativelayout with number

  • 0

I have layout with 5 different child views, Child views are relativelayout with number of child views inside it, and all are different too. Hence i am using scrollview as root container like this:

<ScrollView android:layout_width="match_parent" android:layout_height="match_parent"
        android:fillViewport="true" android:scrollbars="none">

        <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent"
            android:id="@+id/home_page_scrollview_outer_layout">
         <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:layout_marginLeft="10dip"
            android:layout_marginRight="10dip"
            android:layout_alignParentLeft="true"
            android:background="@drawable/homescreen_yellow" >



            <ImageButton android:id="@+id/hp_imgbtn_listA" android:layout_width="wrap_content" android:layout_height="wrap_content"
                 android:layout_alignParentRight="true" android:src="@drawable/arrow_right">
            </ImageButton>    

            <ListView
                android:id="@+id/listA"
                android:layout_below="@id/hp_txt_listA"
                android:background="@color/home_page_bg"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content">
            </ListView>
     </RelativeLayout>

    <!-- List B layout -->    

        <RelativeLayout     
            android:layout_weight="1"
            android:layout_marginRight="10dip"
            android:background="@drawable/homescreen_cyan"
            android:layout_width="match_parent" 
            android:layout_height="wrap_content">


        </RelativeLayout>

     <!-- List C layout -->   

        <RelativeLayout     
            android:layout_weight="1"
            android:layout_marginRight="10dip"
            android:background="@drawable/homescreen_purple"
            android:layout_width="match_parent" 
            android:layout_height="wrap_content">

    </RelativeLayout>  

     <!-- List D layout -->   

        <RelativeLayout 
            android:layout_weight="1"   
            android:layout_marginRight="10dip"
            android:background="@drawable/homescreen_turqoise"
            android:layout_width="match_parent" 
            android:layout_height="wrap_content">

    </RelativeLayout> 

     <!-- List E layout -->   

        <RelativeLayout 
            android:layout_weight="1"   
            android:layout_marginRight="10dip"
            android:background="@drawable/homescreen_turqoise"
            android:layout_width="match_parent" 
            android:layout_height="wrap_content">

    </RelativeLayout> 
    <LinearLayout>
</ScrollView>   

I want to have drag and drop effect LinearLayout container. Any idea how to achieve Drag and Drop for LinearLayout container? I got working example for ListView, I guess for scrollview it should be same too, but scrollview can contain only one child view inside it.

  • 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-05T00:30:04+00:00Added an answer on June 5, 2026 at 12:30 am

    Add this to your onCreate:

     yourView.setOnTouchListener(new OnTouchListener() {
    
            public boolean onTouch(View v, MotionEvent event) {
                // TODO Auto-generated method stub
                drag(event, v);
                return false;
            }
        });
    

    And this to your Activity Class outside any methods.

           public void drag(MotionEvent event, View v)
            {
    
                RelativeLayout.LayoutParams params = (android.widget.RelativeLayout.LayoutParams) v.getLayoutParams();
    
                switch(event.getAction())
                {
                   case MotionEvent.ACTION_MOVE:
                   {
                     params.topMargin = (int)event.getRawY() - (v.getHeight());
                     params.leftMargin = (int)event.getRawX() - (v.getWidth()/2);
                     v.setLayoutParams(params);
                     break;
                   }
                   case MotionEvent.ACTION_UP:
                   {
                     params.topMargin = (int)event.getRawY() - (v.getHeight());
                     params.leftMargin = (int)event.getRawX() - (v.getWidth()/2);
                     v.setLayoutParams(params);
                     break;
                   }
                   case MotionEvent.ACTION_DOWN:
                   {
                    v.setLayoutParams(params);
                    break;
                   }
                }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a basic layout where different components can be selected using a tree
I have Relative Layout containing layers of different Relative layouts and Views. In one
enter code here I have a ListView that have a different Layout XML for
I have multiple similar sites (same layout, just different data), and each of them
I want to have different layouts like [left|content|right] and [left|content] or [content|right] when using
I have a layout defined in XML. It contains also: <RelativeLayout android:id=@+id/item android:layout_width=fill_parent android:layout_height=wrap_content
I have a Panel which hosts a number of child controls in a grid
I have different layout files for different screens size like Folder Structure: layout layout-large
Let say we are in landscape and I have one root container in that
I have used restful-authentication and I have public layout and a completely different members

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.