0

am developing an application in android. Am adding a vertical scroll bar around linear layout.The problem is that only half screen of the layout is visible. I want that scroll view should cover full screen. Here is my full screen layout.

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="fill_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context=".MainActivity"
    android:orientation="vertical" >

    <LinearLayout
        android:id="@+id/linearLayout1"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="0dp"
        android:background="#4ba9d1" >

        <ImageView
            android:id="@+id/imageView1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight=".5"
            android:src="@drawable/logo" />

        <ImageView
            android:id="@+id/imageButton2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight=".2"
            android:src="@drawable/menu_icon" />
    </LinearLayout>


    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="0dp"
        android:background="#242424"
        android:orientation="vertical" >

<LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_marginLeft="20dip"
            android:layout_marginRight="20dip"
            android:layout_marginTop="20dip"
            android:background="#363636"
            android:orientation="vertical" >

            <TextView
                android:id="@+id/head_title"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:fontFamily="@string/fonts"
                android:gravity="center_vertical|center_horizontal"
                android:text="AssetTrac - Experience Zone"
                android:textColor="#fff"
                android:textSize="18sp" />
   </LinearLayout> 
   <ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scrollbars="vertical" >   
<LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_marginLeft="20dip"
            android:layout_marginRight="20dip"
            android:orientation="vertical" >     
<LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_marginLeft="20dip"
            android:layout_marginRight="20dip"
            android:layout_marginTop="10dip"
            android:background="#4ba9d1"
            android:orientation="vertical" >
    <ExpandableListView
        android:id="@+id/expandableListView1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:divider="@drawable/separ"
        >

    </ExpandableListView>
    </LinearLayout>
    <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="50dp"
            android:layout_marginLeft="20dip"
            android:layout_marginRight="20dip"
            android:layout_marginTop="10dip"
            android:background="#4ba9d1"
            android:orientation="vertical" >
            <EditText
                android:id="@+id/signature"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:ems="20"
                android:inputType="textPostalAddress" />
            <Button
                android:id="@+id/save_sig"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginLeft="94dp"
                android:text="Button" />
            <Button
                android:id="@+id/update_status"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginLeft="94dp"
                android:text="Button" />


 </LinearLayout>
 </LinearLayout>
 </ScrollView> 
</LinearLayout>


</LinearLayout>

Any help would me much appreciated.

Thanks :)

Tashen Jazbi
  • 1,068
  • 1
  • 16
  • 41

2 Answers2

0

Add android:fillViewport="true" in your ScrollView tag and it will fill whole screen

Apoorv
  • 13,470
  • 4
  • 27
  • 33
  • with your correction i've also edited scroll view's parent layout hight to fill parent to get full screen display.Now full screen display is available but now scroll is not working. – Tashen Jazbi Dec 11 '13 at 10:37
  • Are any views invisible? – Apoorv Dec 11 '13 at 10:40
  • Then how would it scroll? `ScrollView` only works when there are views that can not be fitted in the screen. – Apoorv Dec 11 '13 at 11:04
0

ScrollView parent's (LinearLayout with background "#242424") height is set to wrap_content. Therefore scrollview height which is fill_parent would have height of content size. Either set the scrollview parent's height as fill_parent or take out the scrollview outside the immediate linear layout tag.

    <LinearLayout
    android:layout_width="fill_parent"
    <!-- Layout Height set to fill_parent -->
    android:layout_height="fill_parent"
    android:layout_marginTop="0dp"
    android:background="#242424"
    android:orientation="vertical" >

       <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_marginLeft="20dip"
        android:layout_marginRight="20dip"
        android:layout_marginTop="20dip"
        android:background="#363636"
        android:orientation="vertical" >

        <TextView
            android:id="@+id/head_title"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:fontFamily="@string/fonts"
            android:gravity="center_vertical|center_horizontal"
            android:text="AssetTrac - Experience Zone"
            android:textColor="#fff"
            android:textSize="18sp" />
      </LinearLayout> 

      <ScrollView
      android:layout_width="fill_parent"
      android:layout_height="fill_parent"
      android:scrollbars="vertical" >  
      ....... 
Ashish Bindal
  • 995
  • 1
  • 8
  • 16
  • thanks Ashish!. Now display is covering full but now scroll is not working :( – Tashen Jazbi Dec 11 '13 at 10:29
  • with your correction i've also added android:fillViewport="true" inside scrollview to get full screen but now scroll is not working. – Tashen Jazbi Dec 11 '13 at 10:32
  • You can't simply put one vertical scrolling item in another scrolling view. ExpandableListview is recognising the gesture and scrollview can't catch that gesture anymore. It's a known issue, find solution at another [thread](http://stackoverflow.com/a/13796159/1779642). Let me know if that works. – Ashish Bindal Dec 11 '13 at 10:44