滚动到ScrollView底部时,不是很流畅
更新:HHH   时间:2023-1-7


滚动到ScrollView底部时,不是很流畅,出现闪烁现象

private void onRequestVodsFinished(int resultCode, IVideoResult result) {
    Logger.v(TAG, "@onRequestVodsFinished.");
    switch (resultCode) {
    case TvieRequest.RESULT_ERROR:
    case TvieRequest.RESULT_EMPTY:
    case TvieRequest.RESULT_CANCEL:
        break;
    case TvieRequest.RESULT_SUCCESS:
        TodayRankResult res = (TodayRankResult) result;
        if (isPullUping()) {
            setPullUping(false);
            vPullToRefresh.onFooterRefreshComplete();
            if (res.getData() == null || res.getData().size() == 0) {
                showToast("没有更多数据了");
            } else {
                listVideo.addAll(res.getData());
                initOrUpdateVods();
                // 滚动到ScrollView的底部
                svVods.post(new Runnable() {
                    public void run() {
                        svVods.fullScroll(ScrollView.FOCUS_DOWN);
                    }
                });
            }
        } else {
            listVideo = res.getData();
            initOrUpdateVods();
        }
    }
}

其中initOrUpdateVods()方法中重新创建了svVods唯一孩子中的内容

private void initOrUpdateVods() {
    vVods.removeAllViews();
    VodAdapter vodAdapter = new VodAdapter(context, listVideo);
    FixedGridLayout gridVod = new FixedGridLayout(context);
    gridVod.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
    gridVod.setRowParams(vVods.getMeasuredWidth() / columns, columns);
    gridVod.setAdapter(vodAdapter);
    vVods.addView(gridVod);
}


返回开发技术教程...