0
我有一个HorizontalScrollView的子类,我在其中添加多个图像。 我必须在屏幕的左右两侧显示某种指示符,以显示左侧和右侧是否有剩余物品。当我们达到相关目标时,各自的指标也应该消失。指标,当我们到达HorizontalScrollView中的最后一个项目时消失
有人可以告诉我可用的选项吗?
protected void onScrollChanged(int l, int t, int oldl, int oldt) {
View view = (View) takeparent().getChildAt(takeparent().getChildCount()-1); //this is the last view
int diff = (view.getRight()-(getRight()+getScrollX()));// Calculate the scrolldiff
if(diff == 0){ // if diff is zero, then the rightmost end has been reached
right.setVisibility(View.GONE); //setting the right button invisible
}
View viewleft = (View) takeparent().getChildAt(0); taking the first View
int diffleft2 = (viewleft.getLeft()-(getLeft()+getScrollX()));// Calculate the scrolldiff
if(diffleft2 == 0){ // if diff is zero, then the bottom has been reached
left.setVisibility(View.GONE);
}
super.onScrollChanged(l, t, oldl, oldt);
}
请问您能解释一下您的答案。我没有得到你。 – user3265443
更新了答案 – Simon
对不起,但我仍然没有得到你,因为它没有提到如何显示和消失指标达到各自的目的。该指标让我们假设是一个按钮 – user3265443