2012-03-16 52 views
1

我用2个线性布局分割屏幕包含文本视图,这可能包含大量线条,因此使用滚动,但我们的第一行被废弃,无法查看它。滚动不显示整个内容

下面的代码片段

<LinearLayout 
    android:layout_width="fill_parent" 
    android:layout_height="200dp" 
    android:orientation="vertical" > 

    <ScrollView 
     android:id="@+id/ScrollView01" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" > 

     <TextView 
      android:id="@+id/question" 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent" 
      android:text="Question" 
      android:textSize="20dp" > 
     </TextView> 
    </ScrollView> 
</LinearLayout> 

<LinearLayout 
    android:layout_width="fill_parent" 
    android:layout_height="250dp" 
    android:orientation="vertical" > 

    <ScrollView 
     android:id="@+id/ScrollView" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" > 

     <TextView 
      android:id="@+id/answer" 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent" 
      android:text="Answer" 
      android:textSize="20dp" 
      android:visibility="invisible" > 
     </TextView> 
    </ScrollView> 
</LinearLayout> 
+0

也显示你的父母布局。 – 2012-03-16 09:17:05

回答

2

而不是去为两个单独ScrollViews你随时都可以对一些属性在您的布局设置。

设置android:maxLinesandroid:scrollbars = "vertical"属性都TextView的公司,然后在相应的活动做了两个TextView中的

TextView textDisplayed =(TextView) findViewById(R.id.textView1); 
textDisplayed.setMovementMethod(new ScrollingMovementMethod()); 

希望这helps.You可能也想看看这link

0

你可以做这样的滚动型父

<ScrollView 
    android:id="@+id/ScrollView01" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" > 
        <LinearLayout 
         android:layout_width="fill_parent" 
         android:layout_height="200dp" 
          android:orientation="vertical" > 
       <TextView 
        android:id="@+id/question" 
         android:layout_width="fill_parent" 
         android:layout_height="fill_parent" 
         android:text="Question" 
         android:textSize="20dp" > 
          </TextView> 


       </LinearLayout> 
       </ScrollView> 

      <ScrollView 
       android:id="@+id/ScrollView" 
       android:layout_width="fill_parent" 
       android:layout_height="fill_parent" > 

     <LinearLayout 
       android:layout_width="fill_parent" 
       android:layout_height="250dp" 
       android:orientation="vertical" > 


       <TextView 
         android:id="@+id/answer" 
         android:layout_width="fill_parent" 
         android:layout_height="fill_parent" 
         android:text="Answer" 
         android:textSize="20dp" 
         android:visibility="invisible" > 
         </TextView> 

       </LinearLayout> 
       </ScrollView>