开发者

TextView In ScrollView Not Scrolling - Android

开发者 https://www.devze.com 2023-02-18 08:44 出处:网络
I\'m completely new to java and .xml programing, and thanks to stack overflow and many other sites, I\'ve been able to get a basic app started.The problem I\'m having is this:I started with a tabbed l

I'm completely new to java and .xml programing, and thanks to stack overflow and many other sites, I've been able to get a basic app started. The problem I'm having is this: I started with a tabbed layout with 4 tabs, and simple textviews with 3-4 pages of text in each tab. When I ran this on an emulator, I found the text wasn't scrolling, so after researching for a while, I figured that I needed a ScrollVi开发者_运维知识库ew in order to see all the text. I've now added the ScrollView, but only the first tab is scrolling. I've been looking all over for an answer, and can't seem to find one. I'm just hoping someone can look at my code, and perhaps see where I went wrong.

<?xml version="1.0" encoding="utf-8"?>
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/tabhost"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">
    <TabWidget
        android:id="@android:id/tabs"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content" />

    <FrameLayout
        android:id="@android:id/tabcontent"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent">
        <ScrollView
            android:id="@+id/ScrollView01"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent">
        <TextView
            android:id="@+id/textview1"                
            android:text="3-4 pages of text here"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:lineSpacingExtra= "5sp"
            android:background="@color/backgroundColor" 
            android:textColor="@color/textColor"/>
            </ScrollView>                
            <ScrollView
                android:id="@+id/ScrollView02"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent">
        <TextView
            android:id="@+id/textview2"                
            android:text="3-4 pages of text here"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:lineSpacingExtra= "5sp"
            android:background="@color/backgroundColor"                                
            android:textColor="@color/textColor"/>
            </ScrollView>                     
            <ScrollView
                android:id="@+id/ScrollView03"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent">  
        <TextView
            android:id="@+id/textview3"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:lineSpacingExtra= "5sp"
            android:text="more text in here" 
            android:background="@color/backgroundColor" 
            android:textColor="@color/textColor"/>
            </ScrollView>                    
            <ScrollView
                android:id="@+id/ScrollView04"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent">
        <TextView
            android:id="@+id/textview4"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:lineSpacingExtra= "5sp"
            android:text="even more text here"
            android:background="@color/backgroundColor" 
            android:textColor="@color/textColor"/>
            </ScrollView>                               
            />                
</FrameLayout>
</LinearLayout>


To make your TextView scrollable, you have to add the following code:

    yourTextView.setMovementMethod(new ScrollingMovementMethod())

Please use the above code and let me know how it goes.

0

精彩评论

暂无评论...
验证码 换一张
取 消