J'ai un petit problème avec un ScrollView. J'ai une mise en page pour une activité qui est faite avec un ScrollView. Cette scrollview contient deux ListViews.Comment faire défiler par programme un ScrollView?
<?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>
Dans la méthode onCreate
de mon activité, je calculer la hauteur listviews selon leur contenu.
Lors de l'exécution, lors du lancement de l'activité, ScrollView fait déjà défiler un bit.
J'ai donc essayé, à la fin de onCreate, d'appeler la méthode scrollTo(0, 0)
, mais cela ne change rien.
Des idées?
Il y a un très bel exemple que vous pouvez plier et faire vraiment flex par Jeff Sharkey http://jsharkey.org/blog/2008/08/18/separating-lists-with-headers-in-android- 09 / –