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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T13:23:00+00:00 2026-06-05T13:23:00+00:00

I have the following structure in my UI <ScrollView android:id=@+id/vscroll android:layout_width=match_parent android:layout_height=match_parent> <TableLayout android:id=@+id/table

  • 0

I have the following structure in my UI

    <ScrollView
        android:id="@+id/vscroll"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <TableLayout
            android:id="@+id/table"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" >
        </TableLayout>

    </ScrollView>

I fill the TableLayout with TableRows programmatically.

Sometimes I need to add rows at the top of the table (insert before child(0)).
And the problem is the ScrollView jumps up.
I can tell you that I Logged the ScrollY() position of the ScrollView before and after the row insertion. And it remains the same (!!)

This is what is causing the jump, because now I have some more rows and scroll position Y= 234 (for example) before was on row A and now the same position Y means row Q.

Row A was the (lt’s say) fifth row, and now after insertion row Q is the fifth row
So you see, from the ScrollView point of view nothing changed, but the View shows now a different Row.

If at this point you are not totally confused with my explanation, then maybe you can advise how can I insert rows at the top without changing what I see on screen.
In other words I want the insertion to go stealth without any influence on what the user sees.

If some code will help clear the picture, here is how I insert 5 rows at the top

table = (TableLayout) findViewById(R.id.table);
TableRow.LayoutParams params = new TableRow.LayoutParams(TableRow.LayoutParams.MATCH_PARENT, TableRow.LayoutParams.WRAP_CONTENT);
for(int i=0; i<5 ; i++) {   
    TableRow mr = new TableRow(getContext());
    // some stuff to set the row texts
    table.addView(mr, 0, params);
}

Before Insertion    After Insertion
Row 0               New Row 0
Row 1               New Row 1
Row 2               New Row 2
Row 3               New Row 3        <--- vscroll Y position stays the same
Row 4               New Row 4
Row 5               Old Row 0
Row 6               Old Row 1
Row 7               Old Row 2
Row 8               Old Row 3        (vscroll jumps up from here to new Row 3)
Row 9               Old Row 4
Row 10              Old Row 5
Row 11              Old Row 6
  • 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-05T13:23:03+00:00Added an answer on June 5, 2026 at 1:23 pm

    I haven’t tested it but you could try to post() a Runnable where you would get the newly inserted row’s height and then scroll the ScrollView by that amount so it stays at the same position:

    final TableRow newRow = new TableRow(this);
            // add stuff to the row     
            tl.addView(newRow, 0, params);
            // sv is your ScrollView vscroll
            sv.post(new Runnable() {
    
                @Override
                public void run() {             
                    int size = newRow.getHeight();              
                    sv.scrollBy(0, size);
                }
    
            });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have following table structure table domains ID | name | ________________________ 1 |
I have following table structure: Table: Plant PlantID: Primary Key PlantName: String Table: Party
I have the following layout structure: ScrollView - LinearLayout - TextView - ImageView -
I have following db structure in mysql. Table: Story Id Name categoryid date 1
I have following table structure <table> <tbody> <tr> <td>Lorem</td> <td>Ipsum</td> <td>Fierent</td> </tr> <tr> <td>Lorem
I have following table structure ID Name Parent_ID 1 abc 0 2 efg 1
I have following table structure in my DB ID Name -------------------------- ID_1 Name1 ID1
I have the following table structure with live data in it: CREATE TABLE IF
I have following structure <table> <tr> <td><img class='show_detail'></td> <tr> <tr class='detail'> <td>XYZ</td> <tr> <tr>
I have following table structure. <table> <tr> <td><a href=#></td> </tr> </table> When I click

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.