0

I have a little problem with a ScrollView. I have a layout for an activity which is made with a ScrollView. This scrollview contains two ListViews.

<?xml version="1.0" encoding="utf-8"?>

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/rootViewGroup" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:scrollbars="vertical">

<LinearLayout android:orientation="vertical"
    android:gravity="top" android:layout_width="fill_parent"
    android:layout_height="wrap_content" android:background="@drawable/cmb_bg">

    <ListView android:id="@+id/accountsListView"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content" android:scrollbars="none" />

    <ListView android:id="@+id/cardsListView"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content" android:scrollbars="none" />

</LinearLayout>

In the onCreate method of my activity I compute ListViews height according their contents.

During execution, on activity launch, ScrollView is already scrolled a bit.

So I tried, at the end of onCreate to call method scrollTo(0, 0), but it does not change anything.

Any ideas?

1 Answer 1

6

AHHH!!! Remove ScrollView and leave only ONE ListView in your activity. It's not intended to work this way .If you want to have different content in your ONE listView - modify your adapter, or change the UI But never, ever put different scrollable containers on the same screen/inside each other here is a related post. http://groups.google.com/group/android-developers/browse_thread/thread/e7c8df374fe31733# In theory you can slap two listview on the screen, but expect things to be weird. And i would really redesign it with with either separators or expanders or just with one ListView.

Sign up to request clarification or add additional context in comments.

1 Comment

There is a very nice example which you can bend and make really flex by Jeff Sharkey jsharkey.org/blog/2008/08/18/…

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.