Android ScrollView USES code examples

  • 2020-06-15 10:13:35
  • OfStack

ScrollView enables controls to scroll out of screen range.
Usage: Include scrollable control in ScrollView file, scroll to view when the control is out of screen scope; ScrollView also provides a number of ways to control your presentation.

1.ScrollView contains other controls


<ScrollView
         android:id="@+id/scrollView_showMessages"
         android:layout_width="fill_parent"
         android:layout_height="310dp"
         >
         <TextView
                   android:id="@+id/textView_showMessages"
                   android:layout_width="fill_parent"
                   android:layout_height="wrap_content"
                   android:textSize="25dp"
                   />
</ScrollView>

2. onCreate findView () :

mScrollView_showMessages=(ScrollView) findViewById(R.id.scrollView_showMessages);


3. Scroll ScrollView to the specified location where desired

mScrollView_showMessages.scrollTo(0, mTextView_showMessages.getBottom());


Related articles: