android input box and text box plus scroll bar scrollview example

  • 2020-05-30 21:02:33
  • 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 with the function of the scroll bar is indispensable for mobile phone, with a scroll bar, actually very simple, need only in a text input box or text box shown above plus the scroll bar control, the control ScrollView name, here we compared (with TextView example).


//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 can make a text box scrollable by simply adding the ScrollView control to the outside of the text control.


Related articles: