-1

Why my TextView field doesn't scroll with finger? Have I missed something?

    <TextView
    android:text="Hi! Type help for more info"
    android:textAppearance="?android:attr/textAppearanceLarge"
    android:layout_width="match_parent"
    android:layout_height="186.0dp"
    android:id="@+id/chat_box"
    android:layout_marginBottom="5dp"
    android:maxLines="12"
    android:textSize="12sp" 

    android:overScrollMode="always"
    android:scrollbarStyle="insideInset"
    android:scrollbars="vertical" />

I've tried solution from another post, but for some reason my TextView doesn't have setMovementMethod(new ScrollingMovementMethod()) method.

arti
  • 645
  • 1
  • 8
  • 27
  • 1
    Possible duplicate of [Making TextView scrollable in Android](http://stackoverflow.com/questions/1748977/making-textview-scrollable-in-android) – KevinZ Apr 21 '17 at 14:13
  • it's not duplicate, other post's solution is completely different and doesn't work. – arti Apr 25 '17 at 07:11

2 Answers2

0

You should add a scrollview for your textview

 private HorizontalScrollView m;
private TextView textview;

now on your on create method initialize text view and scrollview

 m = (HorizontalScrollView) findViewById(R.id.antc);
    textView = (TextView) findViewById(R.id.chat_box);

now you can use scroll view

 m.smoothScrollTo(0, textView.getBottom());

or simply add TextView.setMovementMethod(new ScrollingMovementMethod()); in your code this should work

  • both methods smoothScrollTo() and setMovementMethod() are not available, any reason why? – arti Apr 24 '17 at 07:52
0

It is an old thread but as a reference,

I tried all properties of TextView about 'scrolling' in Xamarin.Android but none of them worked.( Maybe I missed something...) Anyway, I could achieve this in another way

TextView dynamicTextView = new TextView(this);
dynamicTextView.Text = "long text blablabla ";
dynamicTextView.LayoutParameters = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MatchParent, 500); //Limit the height so you can scroll

ScrollView dynamicScrollView = new ScrollView(this);
 dynamicScrollView.AddView(dynamicTextView);
Ebrahim ElSayed
  • 157
  • 2
  • 10