Skip to main content
Active reading. (References to relative positions of answers are not reliable as they depend on the view (votes/newest/active) and changing of the accepted answer and change over time (for votes, active, and accepted state)).
Source Link
Peter Mortensen
  • 31.4k
  • 22
  • 110
  • 134

I struggled with this for over a week, and finally figured out how to make this work! 

My issue was that everything would scroll as a 'block'. The text itself was scrolling, but as a chunk rather than line by line. This obviously didn't work for me, because it would cut off lines at the bottom. All of the previous solutions above did not work for me, so I crafted my own.

Here is the easiest solution by far:

Make a class file called: 'PerfectScrollableTextView' inside a package, then copy and paste this code in:

import android.content.Context; import android.graphics.Rect; import android.util.AttributeSet; import android.widget.TextView; public class PerfectScrollableTextView extends TextView {   public PerfectScrollableTextView(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle);   setVerticalScrollBarEnabled(true);   setHorizontallyScrolling(false); } public PerfectScrollableTextView(Context context, AttributeSet attrs) { super(context, attrs);   setVerticalScrollBarEnabled(true);   setHorizontallyScrolling(false); } public PerfectScrollableTextView(Context context) { super(context);       setVerticalScrollBarEnabled(true);   setHorizontallyScrolling(false);   }   @Override protected void onFocusChanged(boolean focused, int direction, Rect previouslyFocusedRect) { if(focused) super.onFocusChanged(focused, direction, previouslyFocusedRect); } @Override public void onWindowFocusChanged(boolean focused) { if(focused) super.onWindowFocusChanged(focused); }   @Override public boolean isFocused() { return true; } }  

Finally change your 'TextView' in XML:

From: <TextView

To: <com.your_app_goes_here.PerfectScrollableTextView

I struggled with this for over a week, finally figured out how to make this work! My issue was that everything would scroll as a 'block'. The text itself was scrolling but as a chunk rather than line by line. This obviously didn't work for me because it would cut off lines at the bottom. All of the solutions above did not work for me, so I crafted my own.

Here is the easiest solution by far:

Make a class file called: 'PerfectScrollableTextView' inside a package, then copy and paste this code in:

import android.content.Context; import android.graphics.Rect; import android.util.AttributeSet; import android.widget.TextView; public class PerfectScrollableTextView extends TextView {   public PerfectScrollableTextView(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); setVerticalScrollBarEnabled(true); setHorizontallyScrolling(false); } public PerfectScrollableTextView(Context context, AttributeSet attrs) { super(context, attrs); setVerticalScrollBarEnabled(true); setHorizontallyScrolling(false); } public PerfectScrollableTextView(Context context) { super(context);    setVerticalScrollBarEnabled(true); setHorizontallyScrolling(false);   } @Override protected void onFocusChanged(boolean focused, int direction, Rect previouslyFocusedRect) { if(focused) super.onFocusChanged(focused, direction, previouslyFocusedRect); } @Override public void onWindowFocusChanged(boolean focused) { if(focused) super.onWindowFocusChanged(focused); }   @Override public boolean isFocused() { return true; } }  

Finally change your 'TextView' in XML:

From: <TextView

To: <com.your_app_goes_here.PerfectScrollableTextView

I struggled with this for over a week and finally figured out how to make this work! 

My issue was that everything would scroll as a 'block'. The text itself was scrolling, but as a chunk rather than line by line. This obviously didn't work for me, because it would cut off lines at the bottom. All of the previous solutions did not work for me, so I crafted my own.

Here is the easiest solution by far:

Make a class file called: 'PerfectScrollableTextView' inside a package, then copy and paste this code in:

import android.content.Context; import android.graphics.Rect; import android.util.AttributeSet; import android.widget.TextView; public class PerfectScrollableTextView extends TextView { public PerfectScrollableTextView(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle);   setVerticalScrollBarEnabled(true);   setHorizontallyScrolling(false); } public PerfectScrollableTextView(Context context, AttributeSet attrs) { super(context, attrs);   setVerticalScrollBarEnabled(true);   setHorizontallyScrolling(false); } public PerfectScrollableTextView(Context context) { super(context);     setVerticalScrollBarEnabled(true);   setHorizontallyScrolling(false); }   @Override protected void onFocusChanged(boolean focused, int direction, Rect previouslyFocusedRect) { if(focused) super.onFocusChanged(focused, direction, previouslyFocusedRect); } @Override public void onWindowFocusChanged(boolean focused) { if(focused) super.onWindowFocusChanged(focused); } @Override public boolean isFocused() { return true; } } 

Finally change your 'TextView' in XML:

From: <TextView

To: <com.your_app_goes_here.PerfectScrollableTextView

added 69 characters in body
Source Link
Petro
  • 3.7k
  • 4
  • 36
  • 63

I struggled with this for over a week, finally figured out how to make this work! My issue was that everything would scroll as a 'block'. The text itself was scrolling but as a chunk rather than line by line. This obviously didn't work for me because it would cut off lines at the bottom. All of the solutions above did not work for me, so I crafted my own.

Here is the easiest solution by far:

Make a class file called: 'PerfectScrollableTextView' inside a package, then copy and paste this code in:

import android.content.Context; import android.graphics.Rect; import android.util.AttributeSet; import android.widget.TextView; public class PerfectScrollableTextView extends TextView { public PerfectScrollableTextView(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); setVerticalScrollBarEnabled(true); setHorizontallyScrolling(false); } public PerfectScrollableTextView(Context context, AttributeSet attrs) { super(context, attrs); setVerticalScrollBarEnabled(true); setHorizontallyScrolling(false); } public PerfectScrollableTextView(Context context) { super(context); setVerticalScrollBarEnabled(true); setHorizontallyScrolling(false); } @Override protected void onFocusChanged(boolean focused, int direction, Rect previouslyFocusedRect) { if(focused) super.onFocusChanged(focused, direction, previouslyFocusedRect); } @Override public void onWindowFocusChanged(boolean focused) { if(focused) super.onWindowFocusChanged(focused); } @Override public boolean isFocused() { return true; } } 

Finally change your 'TextView' in XML:

From: <TextView

To: <com.your_app_goes_here.PerfectScrollableTextView

I struggled with this for over a week, finally figured out how to make this work! My issue was that everything would scroll as a 'block'. The text itself was scrolling but as a chunk rather than line by line. This obviously didn't work for me because it would cut off lines at the bottom.

Here is the easiest solution by far:

Make a class file called: 'PerfectScrollableTextView' inside a package, then copy and paste this code in:

import android.content.Context; import android.graphics.Rect; import android.util.AttributeSet; import android.widget.TextView; public class PerfectScrollableTextView extends TextView { public PerfectScrollableTextView(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); setVerticalScrollBarEnabled(true); setHorizontallyScrolling(false); } public PerfectScrollableTextView(Context context, AttributeSet attrs) { super(context, attrs); setVerticalScrollBarEnabled(true); setHorizontallyScrolling(false); } public PerfectScrollableTextView(Context context) { super(context); setVerticalScrollBarEnabled(true); setHorizontallyScrolling(false); } @Override protected void onFocusChanged(boolean focused, int direction, Rect previouslyFocusedRect) { if(focused) super.onFocusChanged(focused, direction, previouslyFocusedRect); } @Override public void onWindowFocusChanged(boolean focused) { if(focused) super.onWindowFocusChanged(focused); } @Override public boolean isFocused() { return true; } } 

Finally change your 'TextView' in XML:

From: <TextView

To: <com.your_app_goes_here.PerfectScrollableTextView

I struggled with this for over a week, finally figured out how to make this work! My issue was that everything would scroll as a 'block'. The text itself was scrolling but as a chunk rather than line by line. This obviously didn't work for me because it would cut off lines at the bottom. All of the solutions above did not work for me, so I crafted my own.

Here is the easiest solution by far:

Make a class file called: 'PerfectScrollableTextView' inside a package, then copy and paste this code in:

import android.content.Context; import android.graphics.Rect; import android.util.AttributeSet; import android.widget.TextView; public class PerfectScrollableTextView extends TextView { public PerfectScrollableTextView(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); setVerticalScrollBarEnabled(true); setHorizontallyScrolling(false); } public PerfectScrollableTextView(Context context, AttributeSet attrs) { super(context, attrs); setVerticalScrollBarEnabled(true); setHorizontallyScrolling(false); } public PerfectScrollableTextView(Context context) { super(context); setVerticalScrollBarEnabled(true); setHorizontallyScrolling(false); } @Override protected void onFocusChanged(boolean focused, int direction, Rect previouslyFocusedRect) { if(focused) super.onFocusChanged(focused, direction, previouslyFocusedRect); } @Override public void onWindowFocusChanged(boolean focused) { if(focused) super.onWindowFocusChanged(focused); } @Override public boolean isFocused() { return true; } } 

Finally change your 'TextView' in XML:

From: <TextView

To: <com.your_app_goes_here.PerfectScrollableTextView

Source Link
Petro
  • 3.7k
  • 4
  • 36
  • 63

I struggled with this for over a week, finally figured out how to make this work! My issue was that everything would scroll as a 'block'. The text itself was scrolling but as a chunk rather than line by line. This obviously didn't work for me because it would cut off lines at the bottom.

Here is the easiest solution by far:

Make a class file called: 'PerfectScrollableTextView' inside a package, then copy and paste this code in:

import android.content.Context; import android.graphics.Rect; import android.util.AttributeSet; import android.widget.TextView; public class PerfectScrollableTextView extends TextView { public PerfectScrollableTextView(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); setVerticalScrollBarEnabled(true); setHorizontallyScrolling(false); } public PerfectScrollableTextView(Context context, AttributeSet attrs) { super(context, attrs); setVerticalScrollBarEnabled(true); setHorizontallyScrolling(false); } public PerfectScrollableTextView(Context context) { super(context); setVerticalScrollBarEnabled(true); setHorizontallyScrolling(false); } @Override protected void onFocusChanged(boolean focused, int direction, Rect previouslyFocusedRect) { if(focused) super.onFocusChanged(focused, direction, previouslyFocusedRect); } @Override public void onWindowFocusChanged(boolean focused) { if(focused) super.onWindowFocusChanged(focused); } @Override public boolean isFocused() { return true; } } 

Finally change your 'TextView' in XML:

From: <TextView

To: <com.your_app_goes_here.PerfectScrollableTextView