android development tutorial text box and scrollbar scrollview

  • 2020-05-27 07:08:17
  • OfStack

We all know EditText and TextView is Android text input box and text display box, but based on the size of the phone's screen, if the need to input more words or display more content, mobile phone screen is not enough, so let the text box on his mobile phone have the function of the scroll bar is necessary, how to add a scroll bar is described below.
To add a scrollbar, it is very simple to add a scrollbar control to the text input box or text display box. The name of the control is ScrollView.


//A , no scrolling effect added 
<TextView 
android:layout_width="fill_parent" 
android:layout_height="wrap_content" 
android:id="@+id/textView" 
/>
//B , plus scrolling effect 
<ScrollView 
android:id="@+id/scrollView" 
android:layout_width="fill_parent" 
android:layout_height="200px" 
android:scrollbarStyle="outsideOverlay" android:background="@android:drawable/edit_text"> 
<TextView 
android:layout_width="fill_parent" 
android:layout_height="wrap_content" 
android:id="@+id/textView" 
/> 
</ScrollView>
// As you can see from the above example, you just need to add it to the periphery of the text control ScrollView Control allows the text box to be scrollable. 


Related articles: