public class myScrollView extends ScrollView {
public myScrollView(Context context)
{
super(context);
}
public myScrollView(Context context, AttributeSet attributeSet)
{
super(context,attributeSet);
}
@Override
protected void onScrollChanged(int l, int t, int oldl, int oldt)
{
View view = (View)getChildAt(getChildCount()-1);
int a = view.getBottom();//
//获取View的高度和 竖直屏幕上竖直移动的距离
int b=getHeight()+getScrollY();
a=a-b;
if(d==0)
{
//触底事件
}
if (getScrollY()==0)
{
//触顶事件
}
else
super.onScrollChanged(l,t,oldl,oldt);
}
}
在Activity中新建一个myScrollVie
private myScrollView scrollView;
绑定到xml中的myScrollVie
scrollView=findViewById(R.id.scrollView);
设置到顶
scrollView.fullScroll(ScrollView.FOCUS_UP);
设置到底
scrollView.fullScroll(ScrollView.FOCUS_DOWN);
本文地址:https://blog.csdn.net/Late_whale/article/details/107121383
如对本文有疑问, 点击进行留言回复!!
Xamarin 安卓 相机 各种坑 目标API Android 6以后,我选的目标API版本是 Android 10
Android 9.0+软件某些功能突然暴毙:cleartext not permitted
Android : Resource is not a Drawable (color or path)
Flutter问题集锦——Android Studio 4.0.1 在AVD Manger中启动模拟器报“unable to locate abd”
网友评论