-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.

2
  • 1
    Possible duplicate of Making TextView scrollable in Android Commented Apr 21, 2017 at 14:13
  • it's not duplicate, other post's solution is completely different and doesn't work. Commented Apr 25, 2017 at 7:11

2 Answers 2

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

Sign up to request clarification or add additional context in comments.

1 Comment

both methods smoothScrollTo() and setMovementMethod() are not available, any reason why?
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); 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.