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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T19:36:12+00:00 2026-06-01T19:36:12+00:00

I have an activity in which my views (table and headertable) are overlapping private

  • 0

I have an activity in which my views (table and headertable) are overlapping

private ViewGroup createTable(ViewGroup root) {
    // TODO Auto-generated method stub
    TableLayout table = new TableLayout(getActivity());
    table.setStretchAllColumns(true);
    table.setShrinkAllColumns(true);

    TableLayout headertable = new TableLayout(getActivity());
    headertable.setStretchAllColumns(true);
    headertable.setShrinkAllColumns(true);

    /* Adding stuff to headertable which contains...  */
            /* ...table content I DO NOT WANT to scroll*/

    root.addView(headertable);

    for (int i = -2; i <= 100; i++) {

                    if (i > 0) {
            /*Set up empty views*/
                /*...3 empty views will be set*/
                    }

        /* Adding stuff to table which contains...  */
                    /* ...table content I WANT to scroll*/

    }

    ScrollView sv = new ScrollView(getActivity());
    sv.addView(table);
    root.addView(sv);
    return root;
}

I basically broke a table into headertable and table. I want to scroll table but not headertable. However, my table(which should be below headertable), is overlapping it. Hence, as you can see above I added empty views(so it starts off below headertable(which has three rows)), but realized this would not work. As soon as I scrolled down, the empty views slide up and my headertable gets obstructed again.

All my views have been made programmatically. This activity is a fragment activity.
The XML file contains

<?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"
android:background="#ffffff" >

</FrameLayout>

Any help would be appreciated. Thanks in advance.

  • 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-01T19:36:13+00:00Added an answer on June 1, 2026 at 7:36 pm

    I don’t know if it’s the best way, but here’s how I do it:

    main.xml

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical" >
    <FrameLayout
        android:id="@+id/pane"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />
    </LinearLayout>
    

    header_list.xml

    <?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent" >
        <TextView
                android:id="@+id/header"
                android:layout_width="fill_parent"
                android:layout_height="30dp"
                android:layout_alignParentTop="true" />
        <ListView
                android:id="@id/android:list"
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:layout_below="@id/header" />
        <TextView
                android:id="@android:id/empty"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_below="@id/header"
                android:gravity="center" />
    </RelativeLayout>
    

    RecipeListFragment.java

    public class RecipeListFragment extends ListFragment {
        private TextView header;
        private TextView empty;
        @Override
        public View onCreateView(LayoutInflater inflater, ViewGroup container,
            Bundle savedInstanceState) {
            View v = inflater.inflate(R.layout.common_list, container, false);
            header = (TextView) v.findViewById(R.id.header);
            empty = (TextView) v.findViewById(android.R.id.empty);
            header.setText(R.string.header_recipe);
            empty.setText(R.string.empty_recipes);
            return v;
        }
        @Override
        public void onActivityCreated(Bundle savedInstanceState) {
            super.onActivityCreated(savedInstanceState);
            // List code here
        }
    }
    

    This code only has a single header line, but you can change that TextView to a TableLayout and then fill it the same way, giving you your header table and putting the list underneath it so that it won’t scroll over the top of it.

    Hope this helps!

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

Sidebar

Related Questions

I have a set of table views which the user can switch between using
I have an activity which shows some List entries. When I click on a
I have an activity which needs to make two remote server calls. The first
I have an activity which uses two Loaders. Each of them returns different type
I have an activity which consists of a ListView . The problem is that
I have an Activity which uses a Fragment . I simply want to pass
I am having trouble with my activity management. So I have activity A which
I have created an activity which sends a number of notifications to status bar.
I have an Activity class which has an attribute that references an AsyncTask instance
i have main activity in which i have Four menus. and i have one

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.