Does adding a scrollview push the whole layout to half view size?

I have such a layout.

<LinearLayout android:id="@+id/LinearLayout01" xmlns:android="http://schemas.android.com/apk/res/android" android:layout_height="fill_parent" android:background="#333333" android:orientation="vertical" android:layout_width="match_parent"> <ScrollView android:layout_width="match_parent" android:id="@+id/scrollView1" android:layout_height="match_parent"> <LinearLayout android:id="@+id/linearLayout1" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <FrameLayout android:layout_width="fill_parent" android:layout_height="45dip" android:id="@+id/frameLayout1"> <EditText android:autoText="true" android:text="EditText" android:hint="@string/searchBox" android:singleLine="true" android:layout_height="fill_parent" android:id="@+id/qbox" android:layout_width="fill_parent"></EditText> <Button android:layout_height="fill_parent" android:text="Button" android:layout_width="45dip" android:background="@drawable/search" android:layout_gravity="right" android:id="@+id/search"></Button> </FrameLayout> <LinearLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="vertical"> <LinearLayout android:id="@+id/linearLayout2" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_gravity="center"> <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:paddingRight="5dip" android:id="@+id/logo" android:src="@drawable/icon" android:paddingLeft="10dip"></ImageView> </LinearLayout> <com.app.org.HorizontialListView android:layout_width="wrap_content" android:layout_height="150dip" android:id="@+id/hlist" android:background="#FFFFFF"></com.app.org.HorizontialListView> </LinearLayout> <LinearLayout android:layout_width="fill_parent" android:layout_height="40dip" android:paddingLeft="15dip" android:id="@+id/buttonlist" style="@style/tabBar"></LinearLayout> <ListView android:layout_width="fill_parent" android:background="#FFFFFF" android:id="@+id/searchresults" android:cacheColorHint="#ffffff" android:layout_height="match_parent" android:scrollbars="none"></ListView> </LinearLayout> </ScrollView> </LinearLayout> 

I just added ScrollView, but for some reason it seems to make my whole layout take up about half the screen size. Does anyone have an idea why?

The following is an illustration of the effect of adding Scrollview to the layout.

 Layout before ScollView |---------------------| | | | | | | | | | | | | | | | | | | | | | | | | |---------------------| Layout after ScollView |---------------------| | | | | | | | | | | | | | | |---------------------| 
+4
source share
4 answers

Try setting Full Viewport = true in scroll mode

+17
source

Try adding this to your scrollview tag:

  android:fillViewport="true" 

In addition, it is possible that the ScrollView element should be a parent, not a LinearLayout.

+2
source

set the android:fillViewport to true in ScrollView

android:layout_height="match_parent" not supported / ignored by ScrollView .

+2
source
  • Change the height of the LinearLayout inside the ScrollView to wrap_content instead of match_parent .
  • You cannot put a ListView inside a ScrollView
+1
source

All Articles