ScrollView enables the control to scroll to display when the screen is out of range.
Usage: In an XML file, controls that need to be scrolled are included in ScrollView, which can be viewed by scrolling when the control is out of screen range, and ScrollView provides methods to control its display.
1.ScrollView contains other controls
Copy Code code as follows:
<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:
Copy Code code as follows:
Mscrollview_showmessages= (ScrollView) Findviewbyid (r.id.scrollview_showmessages);
3. Where needed, let ScrollView scroll to the specified location
Copy Code code as follows:
Mscrollview_showmessages.scrollto (0, Mtextview_showmessages.getbottom ());