HorizontalScrollView: auto-scroll to end when new Views are added?

后端 未结 9 1195
鱼传尺愫
鱼传尺愫 2020-11-28 06:37

I have a HorizontalScrollView containing a LinearLayout. On screen I have a Button that will add new Views to the LinearLayout at runtime, and I\'d like the scroll view to

9条回答
  •  孤独总比滥情好
    2020-11-28 07:14

    Use below code for horizontal scrollview {Scroll to right}

    view.post(new Runnable() {
                    @Override
                    public void run() {
                        ((HorizontalScrollView) Iview
                                .findViewById(R.id.hr_scroll))
                                .fullScroll(HorizontalScrollView.FOCUS_RIGHT);
                    }
                });
    

提交回复
热议问题