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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T05:56:23+00:00 2026-05-28T05:56:23+00:00

I am trying to build an Android View, with a listview as a header

  • 0

I am trying to build an Android View, with a listview as a header and footer.
so far only managed that only appears to the header.
Here is a picture that explains what I want and that I’ve got.

Attempt

Does anyone know what I’m doing wrong?
Dry the current code:

<?xml version="1.0" encoding="utf-8"?>  <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent"
    android:orientation="vertical"
    android:background="#ffffff">

<!--  Header Starts-->
<LinearLayout android:id="@+id/header" 
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content" 
        android:background="@layout/header_gradient" 
        android:layout_margin="5dip" 
        android:paddingTop="13dip" 
        android:paddingBottom="8dip">
    <!-- Logo Start-->
    <ImageView android:src="@drawable/logo" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="10dip" />
    <!-- Logo Ends -->
</LinearLayout>
<!--  Header Ends -->

<!-- Content -->
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
              android:layout_height="fill_parent"
              android:layout_width="fill_parent"
              android:orientation="vertical"
              android:gravity="center">

        <LinearLayout android:orientation="horizontal"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_margin="5dip">

            <EditText android:id="@+id/searchText"
                    android:layout_width="fill_parent"
                    android:layout_height="fill_parent"
                    android:layout_weight="1"/>

            <ImageButton android:id="@+id/searchButton"
                    android:layout_height="wrap_content" 
                    android:layout_width="wrap_content" 
                    android:src="@android:drawable/ic_menu_search" />
        </LinearLayout> 

        <ListView android:id="@+id/lstNews" 
                android:layout_height="fill_parent"
                android:layout_width="fill_parent"
                android:layout_marginLeft="5dip"
                android:layout_marginRight="5dip" />
    </LinearLayout>

<!-- Footer Start -->
<LinearLayout android:id="@+id/footer" 
     android:layout_width="fill_parent" 
     android:layout_height="30dip" 
     android:background="@layout/footer_gradient" 
     android:layout_margin="5dip" 
     android:paddingTop="5dip" 
     android:paddingLeft="5dip" 
     android:layout_alignParentBottom="true">
    <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:textColor="#FFFFFF" android:text="Instituto Superior de " />
    <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:textColor="#FFFFFF" android:textStyle="bold" android:text="Engenharia" />
    <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:textColor="#FFFFFF" android:text=" do Porto" />
</LinearLayout>
<!-- Footer Ends --></LinearLayout>
  • 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-28T05:56:24+00:00Added an answer on May 28, 2026 at 5:56 am

    One option is to use a RelativeLayout instead.

    Firstly you will need to change your outermost LinearLayout to a RelativeLayout.

    The next step is to add the property android:layout_above="@id/content" to the header.

    <!--  Header Starts-->
    <LinearLayout android:id="@+id/header" 
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content" 
        android:background="@layout/header_gradient" 
        android:layout_margin="5dip" 
        android:paddingTop="13dip" 
        android:paddingBottom="8dip"
        android:layout_above="@id/content">
    

    The final step is to add the properties android:layout_above="@id/footer" and android:id="@+id/content" to the LinearLayout that contains the content and the listview i.e.

    <!-- Content -->
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
              android:id="@+id/content"
              android:layout_height="fill_parent"
              android:layout_width="fill_parent"
              android:orientation="vertical"
              android:gravity="center"
              android:layout_above="@id/footer">
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to build a custom clock view in Android. See image http://twitpic.com/1devk7 So
I'm trying to build an android app that would do a local search on
I'm trying to build a simple Android app that increments a number displayed every
So I'm trying to build a tabs view for an Android app, and for
I'm trying to build a calendar that looks like Android internal Calendar. The thing
I'm trying to use the Android tutorial to build an app that loads a
I am trying to build an Android Service that should get notified when the
I am trying to build an android app which utilizes the camera, but only
My team is trying to build an Android application for a tablet that will
At the moment I'm trying to build some integration tests for an android project.

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.