ScrollView

来源:互联网 发布:淘宝网车险 编辑:程序博客网 时间:2024/05/22 10:27

纵向 ScrollView
横向 HorizontalScrollView

<ScrollView        android:layout_width="match_parent"        android:layout_height="match_parent"        android:scrollbars="none"        >        <TextView            android:textSize="30sp"            android:id="@+id/text"            android:layout_width="wrap_content"            android:layout_height="wrap_content"            />    </ScrollView>

判断ScrollView到底部

protected void onCreate(Bundle savedInstanceState) {        super.onCreate(savedInstanceState);        setContentView(R.layout.activity_main);        text = (TextView)findViewById(R.id.text);//        text.setText(getResources().getString(R.string.hello_world));        text.setText(R.string.hello_world);        scrollView = (ScrollView)findViewById(R.id.scroll);        scrollView.setOnTouchListener(new View.OnTouchListener() {            @Override            public boolean onTouch(View v, MotionEvent event) {                switch (event.getAction()){                    case MotionEvent.ACTION_MOVE:                        //滑动到底部                        if(scrollView.getChildAt(0).getMeasuredHeight() <= scrollView.getHeight() + scrollView.getScrollY()){                            text.append("aaaaaaaaaaaaaaaaaaaa");                        }                        break;                }                return false;            }        });    }

其他 设置scrollView x y 轴 scrollTo
递增递减 x y 轴 scrollBy

0 0