2

my Android TextView xml is very simple like below, I used style ScrollView but it won't show scrollbar, even when the text is exceeding the bottom and there is no way for me to see what's beyond. How to enable the scrollbar please? I think "match_parent" has issue but don't know how to fix. Thanks!

 <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" android:background="#ffffff"> <TextView android:id="@+id/textResult" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@+id/buttonRecord" android:layout_marginTop="16dp" android:background="@drawable/back" android:editable="true" android:height="150dp" android:text="" android:enabled="false" android:scrollbars="vertical" style="@android:style/Widget.ScrollView" android:layout_alignRight="@+id/buttonRecord" android:layout_alignEnd="@+id/buttonRecord" android:layout_alignLeft="@+id/buttonRecord" android:layout_alignStart="@+id/buttonRecord" /> </RelativeLayout> 
2
  • where is your scrollview?? and change question title...you are trying to get scroll in textview Commented May 31, 2016 at 3:38
  • I think this is a duplicate question with this Commented May 31, 2016 at 5:14

2 Answers 2

0

If you want the content to scroll, perhaps try giving it a fixed height? Right now the height is set to wrap_content due to layout_height. I don't think you should be using android:height at all

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

Comments

0

If you want a fixed height TextView to scroll vertically with scrollbar, define your XML layout file:

<TextView android:id="@+id/textView" android:layout_width="wrap_content" android:layout_height="wrap_content" android:scrollbars="vertical" android:text="@string/text_string" /> 

define your Java class file:

TextView tv = (TextView) findViewById(R.id.textView); tv.setMovementMethod(new ScrollingMovementMethod()); 

1 Comment

This approach is broken - fling won't work. The scroll will stop as soon as you lift your finger off the screen.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.