android-使用HorizontalScrollView自动缓慢滚动
作者:互联网
我有HorizontalScrollView和6 ImageViews在其中.我正在从Parse.com获取图像.我希望活动开始时HorizontalScrollView缓慢滚动.我已经阅读了参考文献,但无法解决.我尝试了这种方法:
new Handler().postDelayed(new Runnable() {
public void run() {
horizontalScrollView1.fullScroll(HorizontalScrollView.FOCUS_RIGHT);
//horizontalScrollView1.smoothScrollBy(500, 0);
}
}, 4000L);
但是,这样做的速度太快了.也许我可以循环处理HorizontalScrollView,以便每个ImageView继续无限重复.有没有办法做到这一点.谢谢
解决方法:
检查这一..
android.widget.HorizontalScrollView horScrlView;
Handler mHandler = new Handler(new Callback() {
@Override
public boolean handleMessage(Message msg) {
horScrlView.smoothScrollBy(5, 0);
mHandler.sendMessageDelayed(new Message(), 1000);
return false;
}
});
/* (non-Javadoc)
* @see android.app.Activity#onCreate(android.os.Bundle)
* @author Hardik Shah
*/
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.horizontal_scroll_view);
horScrlView = (android.widget.HorizontalScrollView) findViewById(R.id.horizontalScrollView1);
mHandler.sendMessageDelayed(new Message(), 1000);
}
标签:horizontalscrollview,android 来源: https://codeday.me/bug/20191030/1964110.html