2011-03-23 243 views
1

我完全不熟悉java和.xml编程,并感谢堆栈溢出和其他许多网站,我已经能够获得一个基本的应用程序启动。我遇到的问题是这样的:我开始使用带有4个选项卡的选项卡式布局,以及每个选项卡中包含3-4页文本的简单文本浏览。当我在模拟器上运行它时,发现文本没有滚动,因此经过一段时间的研究后,我发现我需要一个ScrollView才能看到所有文本。我现在添加了滚动视图,但只有第一个标签滚动。我一直在寻找答案,似乎无法找到答案。我只是希望有人可以看看我的代码,也许看到我出错的地方。TextView在滚动视图不滚动 - Android

<?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> 

回答

0

为了使您的TextView滚动,你必须添加以下代码:

yourTextView.setMovementMethod(new ScrollingMovementMethod()) 

请使用上面的代码,让我知道如何去。