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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T23:31:03+00:00 2026-05-20T23:31:03+00:00

I want to show a button under a ListView . Problem is, if the

  • 0

I want to show a button under a ListView. Problem is, if the ListView gets extended (items added…), the button is pushed out of the screen.

I tried a LinearLayout with weights (as suggested in Android: why is there no maxHeight for a View?), but either I got the weights wrong or it simply didn’t work.

Also, I found somewhere the hint to use a RelativeLayout. The ListView would then be set above the button with the android:layout_above param.

Problem with this is that I don’t know how to position the button afterwards. In the example I found, the View below the ListView was adjusted using android:layout_alignParentBottom, but I don’t want my button to cling to the bottom of the screen.

Any ideas apart from using setHeight-method and some calculating of the required space?


Edit:
I got a lot of useful answers.

  • bigstone’s & user639183’s solution almost worked perfectly. However, I had to add an extra padding/margin to the bottom of the button, as it still would be pushed half way out of the screen (but then stopped)

  • Adinia’s answer with the relative layout only is fine if you want the button fixed to the bottom of the screen. It’s not what I intended but still might be useful for others.

  • AngeloS’s solution was the one I chose at the end as it just created the effects I wanted. However, I made two minor changes to the LinearLayout around the button:

    • First, as I didn’t want to have any absolute values in my layout, I changed android:layout_height="45px" to wrap_content, which works just fine as well.

    • Second, as I wanted the button to be centered horizontally, which is only supported by vertical LinearLayout, I changed android:orientation=”horizontal” to “vertical”.

    AngeloS also stated in his initial post that he was not sure if the android:layout_weight="0.1" param in the LinearLayout around the ListView had any effect; I just tried and it actually does! Without, the button gets pushed out of the screen again.

  • 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-20T23:31:04+00:00Added an answer on May 20, 2026 at 11:31 pm

    I had this exact issue and to solve it I created two seperate LinearLayouts to house the ListView and Button respectively. From there I put both in another Linear Layout and set that container’s android:orientation to vertical. I also set the weight of the the LinearLayout that housed the ListView to 0.1 but I dont know if that has any effect. From there, you can set the height of the bottom container (that has your button) to whatever height you would like.

    EDIT this is what i mean:

    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical">
    
    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_weight="0.1"
        android:orientation="horizontal">
    
        <ListView
            android:id="@+id/ListView01"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:dividerHeight="2px"></ListView>
    </LinearLayout>
    
    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="45px"
        android:background="@drawable/drawable"
        android:orientation="horizontal">
    
        <Button
            android:id="@+id/moreButton"
            android:layout_width="wrap_content"
            android:layout_height="fill_parent"
            android:layout_alignParentRight="true"
            android:background="@drawable/btn_more2"
            android:paddingRight="20px" />
    
    </LinearLayout>
    

    The above solution will fix the button the the bottom of the screen.


    To have the button float at the bottom of the list, change the height of ListView01 to wrap_content:

    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical">
    
    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_weight="0.1"
        android:orientation="horizontal">
    
        <ListView
            android:id="@+id/ListView01"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:dividerHeight="2px"></ListView>
    </LinearLayout>
    
    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="45px"
        android:background="@drawable/drawable"
        android:orientation="horizontal">
    
        <Button
            android:id="@+id/moreButton"
            android:layout_width="wrap_content"
            android:layout_height="fill_parent"
            android:layout_alignParentRight="true"
            android:background="@drawable/btn_more2"
            android:paddingRight="20px" />
    </LinearLayout>
    

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

Sidebar

Related Questions

...I want to Show the 'delete' button when user is an admin, and show
I want to show a chromeless modal window with a close button in the
If you have a button that i want to show on top? how do
I want to show HTML content inside Flash. Is there some way to do
I want to show the publish date in the About dialog.
We want to show a hint for a JList that the user can select
I want to show a table of fixed width at the center of browser
I want to show first element that is hidden by jquery. my html code
I want to show a label rotated 90 degrees (so I can put a
I want to show a message box when users trying to do any major

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.