Explanation of ScrollView (scroll bar):
First, for ScrollView scroll bar is still very good understanding, a total of two kinds of horizontal and vertical, ScrollView and Horizontalscrollview, this inside do not know what to write, say a few ways it
Scrollview.fullscroll (ScrollView.FOCUS.DOWN): Back to the lower part
Scrollview.fullscroll (ScrollView.FOCUS.UP): Back to Top
Scrollview.setverticalsrcollbarenabled (FALSE): Hides the slider (as if the setting is useless)
Android:scrollbarthumbvertical: Set a picture that scrolls vertically (as if it doesn't work)
Android:scrollbarthumbhorizontal: Set a picture that scrolls horizontally (as if it doesn't work)
Android:srollbars = "None" hides the slider (as if the setting is useless)
If we want to control the sliding speed of the slider we need to inherit the method of ScrollView replication public void Fling (int velocityy), this person feels separate summary scrollview nothing to say, first of all.
Two. Simple to use
<?XML version= "1.0" encoding= "Utf-8"?><LinearLayoutxmlns:android= "Http://schemas.android.com/apk/res/android"Android:layout_width= "Match_parent"Android:layout_height= "Match_parent"android:orientation= "vertical"> <ButtonAndroid:id= "@+id/btn1"Android:layout_width= "Match_parent"Android:layout_height= "Wrap_content"Android:text= "Back to Top"/> <ButtonAndroid:id= "@+id/btn2"Android:layout_width= "Match_parent"Android:layout_height= "Wrap_content"Android:layout_margintop= "10DP"Android:text= "Back to bottom"/> <ScrollViewAndroid:id= "@+id/sv"Android:layout_width= "Match_parent"Android:layout_height= "Wrap_content"> <TextViewAndroid:id= "@+id/tv1"Android:layout_width= "Match_parent"Android:layout_height= "Wrap_content"android:scrollbarthumbvertical= "@mipmap/ic_launcher"Android:text= "haha"/> </ScrollView></LinearLayout>
Java code
PackageCom.example.test3;Importandroid.app.Activity;ImportAndroid.os.Bundle;ImportAndroid.view.View;ImportAndroid.widget.Button;ImportAndroid.widget.ScrollView;ImportAndroid.widget.TextView; Public classMainactivityextendsActivityImplementsview.onclicklistener{PrivateTextView TextView; PrivateScrollView ScrollView; PrivateButton btn1; PrivateButton btn2; @Overrideprotected voidonCreate (Bundle savedinstancestate) {Super. OnCreate (savedinstancestate); Setcontentview (R.layout.activity_main); TextView=(TextView) Findviewbyid (R.ID.TV1); ScrollView=(ScrollView) Findviewbyid (R.ID.SV); BTN1=(Button) Findviewbyid (R.ID.BTN1); BTN2=(Button) Findviewbyid (R.ID.BTN2); Btn1.setonclicklistener ( This); Btn2.setonclicklistener ( This); StringBuffer SB=NewStringBuffer (); for(inti = 0;i < 100;i++) {sb.append ("Hehe" + i + "\ n"); } textview.settext (Sb.tostring ()); } @Override Public voidOnClick (view view) {Switch(View.getid ()) { Caser.id.btn1:{Scrollview.fullscroll (SCROLLVIEW.FOCUS_UP); Break; } Caser.id.btn2:{Scrollview.fullscroll (Scrollview.focus_down); Break; } } }}
:
Android Basic Control Learning-----ScrollView