TextView can also slide

There is too much text displayed during coding, and the design requires that the content be slidable. I usually wrap it with a ScrollView, but today I learned about a property that allows the TextView to slide when there is too much content. This property is very good.

Step 1: Add the android:scrollbars="vertical" attribute to indicate whether you can slide horizontally or vertically

<TextView
                android:id="@+id/tv_content"
                android:scrollbars="vertical"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_marginLeft="19dp"
                android:includeFontPadding="false"
                android:textColor="#333333"
                android:textSize="15sp" />

Step 2: Set this control, this attribute must be added

 

 tv_content = mView.findViewById(R.id.tv_content);
//然后TextView支持点击
tv_content.setMovementMethod(ScrollingMovementMethod.getInstance());

Then you can slide and record it. If you see this, give it a like. Thank you! !

 

 

 

Guess you like

Origin blog.csdn.net/qq_25462179/article/details/117441852