如何知道ListView的最后一行是否完全显示?

Arc*_*rci 4 android listview

我知道如何检查ListView的最后一行是否可见.但是,可见并不能保证行完全显示.如何检查最后一行是否完全显示?

Arc*_*rci 5

解决方案是将ListView的高度与页脚的底部位置进行比较.

public void onScroll(AbsListView arg0, int arg1, int arg2, int arg3)
{
    if(arg1 + arg2 == arg3) //If last row is visible. In this case, the last row is the footer.
    {
        if(footer != null) //footer is a variable referencing the footer view of the ListView. You need to initialize this onCreate
        {
            if(listView.getHeight() == footer.getBottom()) //Check if the whole footer is visible.
                doThisMethod();
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

为了他人的利益,页脚基本上是View我添加到ListView通过的addFooterView.R.layout.footer是页脚的布局.下面是我如何初始化页脚并将其添加到以下内容的示例代码ListView:

View footer; //This is a global variable.
....
//Inside onCreate or any method where you initialize your layouts
footer = getLayoutInflater().inflate(R.layout.footer, null);
listView.addFooterView(footer);
Run Code Online (Sandbox Code Playgroud)