Skip to content Skip to sidebar Skip to footer

Scroll Multiple Textviews Simultaneously

I have a string from a file that am storing into 3 separate TextViews because I was having alignments issues with a single TextView. How can I scroll only this section of my scree

Solution 1:

You can place your TextViews inside a HorizontalScrollView in your XML file, like this

<HorizontalScrollViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"><TextView... /><TextView... /><TextView... /></HorizontalScrollView>

Solution 2:

set android:ellipsize="marquee" for your textViews in layout file and setSelected(true) in your code where your are setting text. I Hope this will help you.

Solution 3:

You can use the following xml with a few tweaks if needed,

<HorizontalScrollViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"><TextViewandroid:id="@+id/dp1"... /><TextViewandroid:id="@+id/dp2"... /><TextViewandroid:id="@+id/dp3"... /></HorizontalScrollView>

And now in your java code, you can access them as,

TextViewtextV1= (TextView)findViewById(R.id.dp1);
TextViewtextV2= (TextView)findViewById(R.id.dp2);
TextViewtextV3= (TextView)findViewById(R.id.dp3);

textV1.setText(text1);
textV2.setText(text2);
textV3.setText(text3);

if you want you can use vertical scroll bars as,

<ScrollViewxmlns:android="http://schemas.android.com/apk/res/android"android:scrollbars="vertical"android:layout_height="set the height here" ></ScrollView>

Post a Comment for "Scroll Multiple Textviews Simultaneously"