I have an activity which is displaying walking directions as text. I have a group of TextViews, 5 contain "Step x" where x is the step number and 5 more TextViews which contain the actual instructions.
The problem is that the last TextView goes of screen so I want to have the group of TextViews scroll as if they're one. Is this possible? I know ScrollView seems to only take one TextView as a child.
I was thinking of having all the text in one TextView however I would not be able to apply styling to the "Step x" text individually.
You can just put all your text views into a LinearLayout and then put that layout into the ScrollView.
Here's how I'd do it:
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scrollbars="horizontal" android:id="@+id/ScrollView">
<LinearLayout
android:layout_width="fill_parent"
android:orientation="vertical"
android:id="@+id/linearLayout1"
android:layout_height="fill_parent"
android:layout_gravity="center_vertical|center_horizontal">
<TextView android:text="@string/textView1"
android:id="@+id/textView1"
android:layout_width="280dip"
android:layout_height="60dip">
</TextView>
<TextView android:text="@string/textView2"
android:id="@+id/textView2"
android:layout_width="280dip"
android:layout_height="60dip">
</TextView>
<TextView android:text="@string/textView3"
android:id="@+id/textView3"
android:layout_width="280dip"
android:layout_height="60dip">
</TextView>
<TextView android:text="@string/textView4"
android:id="@+id/textView4"
android:layout_width="280dip"
android:layout_height="60dip">
</TextView>
</LinearLayout>
</ScrollView>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With