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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T05:02:04+00:00 2026-05-21T05:02:04+00:00

I have a vertical LinearLayout with 2 views on top of each other. The

  • 0

I have a vertical LinearLayout with 2 views on top of each other.
The top view should be an expandable panel – if clicked, it should expand down, but without affecting the other view.
I want the bottom view to always be aligned by the “closed” version of the top view.
The top view should animate to the opened version, so I can’t just hide the opened version behind.

How would you accomplish this?

  • 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-21T05:02:04+00:00Added an answer on May 21, 2026 at 5:02 am

    A LinearLayout will not allow what you are asking for. There are no set of layout parameters that will allow children in a LinearLayout to overlap.

    You could use a FrameLayout instead. The trick here is getting the layout just right. Here is one example of how you might do it. The ImageViews with ID’s of topview and bottomview are the views you care about, the rest is structure to get the views to be where you want them.

    <?xml version="1.0" encoding="utf-8"?>
    <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent">
    <LinearLayout 
            android:orientation="vertical" 
            android:layout_width="fill_parent"
            android:layout_height="fill_parent">
            <ImageView
                android:layout_width="fill_parent"
                android:layout_height="70dip" />
            <ImageView
                android:id="@+id/bottomview"
                android:layout_width="fill_parent"
                android:layout_height="0dip"
                android:layout_weight="1"
                android:background="#FFFF0000"/>
    </LinearLayout>
    <ImageView
                android:id="@+id/topview"
                android:layout_width="fill_parent"
                android:layout_height="70dip" 
                android:background="#FF00FF00"/>
    </FrameLayout>
    

    Then you just need to add an onClick listener to the top view and change the layout params. For example, here is a quick example of expanding the view.

        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
    
            setContentView(R.layout.main);
    
            ImageView i=(ImageView)findViewById(R.id.topview);
            i.setOnClickListener(new OnClickListener() {            
                @Override
                public void onClick(View v) {
                    // Make the view bigger
                    FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT,300);
                    v.setLayoutParams(lp);
                    v.invalidate();
                }
            });
    
    ... more code...
    

    The rest would be adding code to keep track of expand/collapse state and adding animation.

    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 this linear layout vertical orientation, containing three views, I want first view
I have 2 views one is a scroll view and the other is a
I have a vertical LinearLayout which has a list view and one ImageView at
I have a simple vertical LinearLayout in which there is a button on the
I have a JSplitPane with a vertical split. The top component is a table
I have two image views, which I am trying to put into a vertical
I've got three views in my activity in a linear vertical layout. The top
I have a LinearLayout oriented vertically, and I'm trying to add three sub-views to
I have a custom view, extending LinearLayout and im trying to add some custom
I'm having a difficult time lining up my text views directly underneath each other.

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.