2012-03-16 56 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>