How to display multiple lines of scroll text in android?

I want to display several lines of text in my application in a certain range so that the user can view other lines. I tried EditText , but it generates a keyboard on top of it and does not scroll. Then I tried TextView , it also does not scroll the text the way I wanted.

Is there any other option? If not, then how to scroll text vertically in a TextView or EditText ? I want to scroll text while dragging and dropping, as in a WebView . NOT auto scrolling.

+6
source share
5 answers

You can limit the height of the TextView to match the number of lines you want to see, and then just enter the TextView in the ScrollView

I made a simple example to demonstrate this ...

 <ScrollView android:layout_height="30dp" android:layout_width="match_parent"> <TextView android:layout_width="match_parent" android:layout_height="30dp" android:textSize="16sp" android:id="@+id/tv1" /> </ScrollView> 
+9
source

You can create a multi-line text view with a scroll list. In your application, I used the following code:

 Txt_VistaRecetasola = (TextView) findViewById(R.id.txt_vistarectsola); Txt_VistaRecetasola.setMovementMethod(ScrollingMovementMethod.getInstance()); Txt_VistaRecetasola.setScrollBarStyle(0x03000000); Txt_VistaRecetasola.setVerticalScrollBarEnabled(true); Txt_VistaRecetasola.setTextColor(0xFF000000); 
+2
source

Check code below

  <TextView android:layout_width="fill_parent" android:layout_height="match_parent" android:textColor="#000000" android:textSize="17dip" android:inputType="textMultiLine" android:scrollbars="vertical" /> 
+1
source

Try using Edittext to make it inaccessible for editing, so in this case it will not allow popping up on the keyboard.

0
source

android:windowSoftInputMode="stateAlwaysHidden" in your manifest file in action, where you have your own EditText.

0
source

Source: https://habr.com/ru/post/913120/


All Articles