0

Hi I am a newbie in android development and confused about how to make TextView in a widget (remoteviews) scrollable. I have add android:scrollbars="vertical" in attributes of TextView, however, it makes no response when I touch it. Can any one please tell me how to solve this, thanks a lot.

Here is the screenshot.

Here is the code.

HeyAlex
  • 1,666
  • 1
  • 13
  • 31
Aneureka
  • 11
  • 2
  • It might be tricky as it's a RemoteView and not all the attributes of the normal Views work. I would try having the TextView as a single element of a ListView and populate that with a RemoteViewsService (See the ['Using App Widgets with Collections'](https://developer.android.com/guide/topics/appwidgets/#collections)) It is not meant to be used like that, but it should work. – Alex Styl Oct 27 '18 at 19:53

3 Answers3

0

To make textview text scrollable you can use ScrollView widget like this

<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">
  <Your TextView Code/>
</ScrollView>
ShehrozEK
  • 180
  • 1
  • 1
  • 6
0

try this example

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/textview"
    android:maxLines = "3"
    android:scrollbars="vertical"
    android:layout_alignTop="@+id/imageView"
    android:layout_toEndOf="@+id/imageView"
    android:layout_toRightOf="@+id/imageView"></TextView>

In java,

TextView txtview=(TextView)findViewById(R.id.textview);
    String text="your text";
    txtview.setText(text);
    txtview.setMovementMethod(new ScrollingMovementMethod());
Vishal Sharma
  • 1,051
  • 2
  • 8
  • 15
  • Thank you! But how can I get the TextView from the RemoteViews Object? I can only get the view of the widget via RemoteViews now. – Aneureka Oct 26 '18 at 15:18
-1

Once you have a reference to your TextView, now you can try this:

TextView nameOfYourTextView = findViewById(R.id.id_of_your_text_view);    
nameOfYourTextView.setMovementMethod(new ScrollingMovementMethod());
Jorge Aguilar
  • 3,442
  • 30
  • 34
AhmetAcikalin
  • 328
  • 2
  • 7