Originally wanted to do a display text message, when the text is many when the height of the view can not exceed a fixed value, when the text is very small when the height of the view is less than that fixed value, according to the view height display. Because ScrollView no maxheight, unable to meet the demand, had to find another way.
The view itself can be set scrollbar, so it doesn't have to rely on ScrollView. TextView has a property maxline, so that it satisfies the demand, as long as the setting of a textview with ScrollBar, and then set Maxline it can be.
<TextView Android:id="@+id/text_view"Android:layout_width="fill_parent"Android:layout_height="wrap_content"Android:singleline="false"Android:maxlines="Ten"Android:scrollbars="Vertical"/>
You also need to set the TextView in the code to scroll.
TextView TextView = (TextView) Findviewbyid (R.id.text_view); Textview.setmovementmethod (Scrollingmovementmethod.getinstance ());
If you use ScrollView, the code is as follows
<ScrollView android:layout_width="745dip"Android:layout_height="520dip"Android:id="@+id/mbtnre2"Android:layout_margintop="30dip"Android:layout_marginleft="30dip"Android:fadingedge="None"> <TextView android:layout_width="fill_parent"Android:layout_height="fill_parent"Android:id="@+id/mtxtcontent"android:textsize="25SP"Android:textcolor="#000000"Android:fadingedge="None"/></scrollview>
ScrollView can adjust the sliding speed, the realization of their own scrollview
FastSlow Slide ScrollView*@author Peasant Uncle* */ Public classSlowscrollview extends ScrollView { PublicSlowscrollview (context context, AttributeSet attrs,intDefstyle) {Super (context, attrs, Defstyle); } PublicSlowscrollview (Context context, AttributeSet Attrs) {Super (context, attrs); } PublicSlowscrollview (Context context) {super (context); } /** * Sliding events*/@Override Public voidFlingintvelocityy) {super.fling (Velocityy/4); } }
Android TextView with scroll bar, and ScrollView usage (temporarily feel scrollview sliding speed relatively fast)