public class CustomScrollView extends ScrollView {
public CustomScrollView(Context context) {
super(context);
// TODO Auto-generated constructor stub
}
public CustomScrollView(Context context, AttributeSet attrs) {
super(context, attrs);
// TODO Auto-generated constructor stub
}
private toShowInterface callback;
public interface toShowInterface {
void toShow(int t);
};
public void setCallback(toShowInterface callback) {
this.callback = callback;
}
@Override
protected void onScrollChanged(int l, int t, int oldl, int oldt) {
// TODO Auto-generated method stub
super.onScrollChanged(l, t, oldl, oldt);
callback.toShow(t);
}
}
回调
@Override
public void toShow(int t) {
// LogUtil.log("toShow=" + t + "/topImg=" + topImg.getHeight());
if (topImg.getHeight() <= t ) {
labelCheckView2.setVisibility(View.VISIBLE);
} else {
labelCheckView2.setVisibility(View.GONE);
}
}