Making TextView scrollable on Android
You don't need to use a ScrollView
actually.
Just set the
android:scrollbars = "vertical"
properties of your TextView
in your layout's xml file.
Then use:
yourTextView.setMovementMethod(new ScrollingMovementMethod());
in your code.
Bingo, it scrolls!
How to make a TextView scrollable in a fragment?
I would suggest to use ScrollView
:
<ScrollView
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:orientation="vertical">
<TextView
android:id="@+id/atomicNumberDefinition"
android:text="The atomic number..... "
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#000000"
android:textSize="24sp" />
</ScrollView>
how to make Textview scrollable and also make it swipeable in android
Scrollable TextView: Put the TextView as the child of a ScrollView.
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World!" />
</ScrollView>
Remember that a ScrollView can only hold ONE object.
For Gestures, look at Detecting Common Gestures
EDIT:
You can also use this line of code in the XML and see if it works (with the textview):
android:scrollbars="vertical"
How can I make a TextView automatically scroll as I add more lines of text?
As per answer here Making TextView Scrollable in Android
You don't need to use a ScrollView actually.
Just set the
android:maxLines = "AN_INTEGER"
android:scrollbars = "vertical"
properties of your TextView in your layout's xml file.Then use:
yourTextView.setMovementMethod(new ScrollingMovementMethod());
in your code.
That will work..
Related Topics
The Application May Be Doing Too Much Work on Its Main Thread
How to Retrieve Data from Firebase to My Adapter
Android Studio: Add Jar as Library
Android: How to Handle Right to Left Swipe Gestures
Can't Find Theme.Appcompat.Light For New Android Actionbar Support
How to Exit from the Application and Show the Home Screen
Android Intent Filter For a Particular File Extension
How to Transfer Some Data to Another Fragment
How to Convert a Base64 String into a Bitmap Image to Show It in a Imageview
Getviewtypecount and Getitemviewtype Methods of Arrayadapter
How to Find the Latitude and Longitude from Address
How to Hook into the Power Button in Android
Get Root View from Current Activity