Bonjour,

J'ai un petit souci dont je n'arrive pas à trouver la cause.
J'ai une Activity composée d'un LinearLayout encapsulé dans un ScrollLayout.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
    android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="10dp"
    android:paddingBottom="@dimen/activity_vertical_margin"
    tools:context="activity.ResultActivity"
    android:id="@+id/result_main">
 
    <view.VerticalScrollView
        android:orientation="vertical"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_centerVertical="true"
        android:layout_alignParentRight="true"
        android:layout_alignParentEnd="true"
        android:id="@+id/scroll">
 
        <LinearLayout
            android:orientation="vertical"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:id="@+id/list"></LinearLayout>
 
    </view.VerticalScrollView>
</RelativeLayout>
Le LinearLayout est construit dynamiquement. Je souhaite charger ce LinearLayout avec des données complémentaires lorsque l'utilisateur a scrollé jusqu'en bas de la page.
Pour savoir quand le bas de la page est atteint, j'ai redéfini la méthode ScrollView.onScrollChanged() :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
 
public class VerticalScrollView extends ScrollView {
 
    private IVerticalScrollListener listener;
    private LinearLayout list;
 
    public VerticalScrollView(Context context, AttributeSet attributes) {
        super(context, attributes);
    }
 
    public void setListener(IVerticalScrollListener listener) {
        this.listener = listener;
    }
 
    @Override
    protected void onScrollChanged(int x, int y, int oldx, int oldy) {
        super.onScrollChanged(x, y, oldx, oldy);
 
        if (list == null) {
            list = (LinearLayout) findViewById(R.id.list);
        }
 
        final int bottom = list.getMeasuredHeight();
        if (y >= bottom) { // cette condition n'est jamais atteinte !!!
            listener.onPageBottomReached();
        }
    }
 
}
Le problème est que les valeurs "y" et "bottom" ne concordent jamais. "y" reste toujours strictement inférieur d'environ 20% de la hauteur du LinearLayout.
Quelqu'un voit-il d'où vient mon problème ?

Merci.