Reputation: 4563
I am creating application which is having textview with lots of text and want to perform automatic vertical scrolling till the text ends. But i am not getting the way to perform automatic scroll.
I have reffred https://github.com/blessenm/SlideshowDemo project. But could not get success with this code..
Here is my XML Code :
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/vertical_scrollview_id"
android:layout_width="wrap_content"
android:layout_height="0dip"
android:layout_weight="1.0"
android:fadingEdge="none"
android:scrollbars="none"
>
<LinearLayout
android:id="@+id/vertical_outer_layout_id"
android:layout_width="fill_parent"
android:layout_height="350dp"
android:orientation="vertical"
android:layout_marginTop="67dp"
android:paddingBottom="100dp"
>
<TextView
android:id="@+id/lyricView"
android:layout_width="fill_parent"
android:layout_height="250dp"
android:layout_marginTop="67dp"
android:background="#000000"
android:gravity="center"
android:maxLines="16"
android:paddingBottom="5dp"
android:paddingTop="8dp"
android:textColor="#ffffff"
android:textStyle="bold"
android:width="200dp" />
<ProgressBar
android:id="@+id/showLoading"
style="?android:attr/progressBarStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="-150dp"
android:background="#000000" />
</LinearLayout>
</ScrollView>
Pleaze give me some idea. Thanx in advance. My simple scrolling functionality works well. But i want to perform automatic vertical scroll..
Upvotes: 0
Views: 1008
Reputation: 6751
When you have content that fits your screen which doesn't need scrollview, it doesn't appear. But when your content exceeds the screen, then the scrollview comes into picture. You have to change the height attribute of textview to wrap_content
to make it automatically increase its height as per content.
Try this:
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#e6e6fa"
android:padding="5dp">
<LinearLayout
android:id="@+id/vertical_outer_layout_id"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_marginTop="67dp"
android:paddingBottom="100dp"
>
<TextView
android:id="@+id/lyricView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="67dp"
android:background="#000000"
android:gravity="center"
android:maxLines="16"
android:paddingBottom="5dp"
android:paddingTop="8dp"
android:textColor="#ffffff"
android:textStyle="bold"
android:width="200dp" />
<ProgressBar
android:id="@+id/showLoading"
style="?android:attr/progressBarStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="-150dp"
android:background="#000000" />
</LinearLayout>
</ScrollView>
Upvotes: 1
Reputation: 28823
Try putting text view alone inside scrollview as:
<ScrollView
android:id="@+id/content_scroll"
android:layout_width="fill_parent"
android:layout_height="250dp"
android:layout_margin="7dip"
android:scrollbars="none" >
<TextView
android:id="@+id/lyricView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="67dp"
android:background="#000000"
android:gravity="center"
android:maxLines="16"
android:paddingBottom="5dp"
android:paddingTop="8dp"
android:textColor="#ffffff"
android:textStyle="bold"
android:width="200dp" />
</ScrollView>
Upvotes: 2