是否可以阻止ListView
滚动?我目前有一个ListView
,上面有一个边距,可以显示一个位于后面的图像视图。我的目标是覆盖人员向上滚动时位于ImageView
后面的ListView
,因为ListView
向上滚动它也会关闭它最终隐藏ImageView
的边距{1}}位于它后面。我目前正在做这件事,但我想弄清楚如何停止ListView
上的滚动动画,直到ListView
关闭它的边距。 ('mainItemDisplayer'是ListView
。)
public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
//mainItemDisplayer.dispatchTouchEvent(MotionEvent.obtain(SystemClock.uptimeMillis(), SystemClock.uptimeMillis(), MotionEvent.ACTION_CANCEL, 0, 0, 0));
int scrolledOffset = mainItemDisplayer.getVerticalScrollOffset();
if (scrolledOffset!=mainItemDisplayer.mInitialScroll) {
//if scroll position changed
boolean scrollUp = (scrolledOffset - mainItemDisplayer.mInitialScroll) < 0;
mainItemDisplayer.mInitialScroll = scrolledOffset;
if (scrollUp){
Log.d("Scrolling", "UP");
} else {
//mainItemDisplayer.setEnabled(false);
//Scrolling down
Log.d("Scrolling", "DOWN");
FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) mainItemDisplayer.getLayoutParams();
//layoutParams.setMargins(0, mainItemDisplayer.mInitialScroll, 0, 0);
layoutParams.height += scrolledOffset;
mainItemDisplayer.setLayoutParams(layoutParams);
//((FrameLayout.LayoutParams) mainItemDisplayer.getLayoutParams()).setMarginEnd(mainItemDisplayer.mInitialScroll);
//mainItemDisplayer.setLayoutParams(layoutParams);
return;
}
}
//mainItemDisplayer.setEnabled(true);
}
答案 0 :(得分:0)
我不确定我理解你想要达到的目标,但听起来你需要的只是列表视图的两个xml属性:
paddingTop="<yourmargin>dp"
和(诀窍!)
clipToPadding="false"
。