1

I am splitting the screen with 2 linear layouts containing text view and this may contain large number of lines hence using scrolls but the first we lines are scrapped off and cannot view it.

Following is a code snippet

  <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>
Nikhil
  • 2,168
  • 6
  • 33
  • 51

2 Answers2

2

Rather than going for two seperate ScrollViews you can always opt out for few properties setting in your layout.

Set the android:maxLines and android:scrollbars = "vertical" property for both the textview's and then in your corresponding activity do this for both the textview's

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

Hope this helps.You might also want to have a look at this link

Community
  • 1
  • 1
Deva
  • 3,919
  • 1
  • 27
  • 38
0

you can do like this ScrollView as parent

    <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>
Nikhil Lamba
  • 593
  • 1
  • 6
  • 17