如何使用 Rxjava 在 android 的时间后到达 ScrollView 的底部?

How to get to the bottom of ScrollView after amount of time in android with Rxjava?

我想在单击某个按钮后到达滚动视图的底部,但我很难做到:(。 提前致谢

你可以用 Rxjava 做到这一点,但你可能应该研究这个场景,找到一个更好的方法来代替这个, 这里有一个指南可以帮助你。

 Observable.interval(400, TimeUnit.MILLISECONDS)//amount of time
                    .take(4)//as many times as you want
                    .observeOn(AndroidSchedulers.mainThread())
                    .subscribe(
                            onNext -> scrollView.fullScroll(View.FOCUS_DOWN)
                    );

要在单击按钮时到达滚动视图的底部,您可以这样做:

public void onButtonClick(View view){
    ScrollView scrollview = ((ScrollView) findViewById(R.id.scrl));
    scrollview.post(new Runnable() {
        @Override
        public void run() {
            scrollview.fullScroll(ScrollView.FOCUS_DOWN);
        }
    });
}