private void autoScroll()
{
this.scrollView = (ScrollView) findViewById(R.id.contentAreasss);//scroll对象
this.mlayout = (LinearLayout) findViewById(R.id.contentArea);//scrollView中包含
mHandler.post(ScrollRunnable);
}
private Runnable ScrollRunnable = new Runnable()
{
public void run()
{
int off = mlayout.getMeasuredHeight() - scrollView.getHeight();//判断高度
if (off > 0)
{
scrollView.scrollTo(0, off);
}
}
};
{
this.scrollView = (ScrollView) findViewById(R.id.contentAreasss);//scroll对象
this.mlayout = (LinearLayout) findViewById(R.id.contentArea);//scrollView中包含
mHandler.post(ScrollRunnable);
}
private Runnable ScrollRunnable = new Runnable()
{
public void run()
{
int off = mlayout.getMeasuredHeight() - scrollView.getHeight();//判断高度
if (off > 0)
{
scrollView.scrollTo(0, off);
}
}
};
本文介绍了一种在Android应用中实现自动滚动视图的方法。通过获取ScrollView及其内部LinearLayout的高度差来确定滚动位置,并使用Runnable对象配合Handler实现延迟执行滚动操作。
1811

被折叠的 条评论
为什么被折叠?



