开发者

Adding Scrollview pushes entire layout to half view size?

I've got a layout like so..

<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="fi开发者_如何学JAVAll_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 the ScrollView but it appears to push my entire layout into taking up about half the screen size for some reason.. anyone got any Idea why?

Below is an illustration of the affect adding the Scrollview had on the Layout.

Layout before ScollView
|---------------------|
|                     |
|                     |
|                     |
|                     |
|                     |
|                     |
|                     |
|                     |
|                     |
|                     |
|                     |
|                     |
|---------------------|

Layout after ScollView
|---------------------|
|                     |
|                     |
|                     |
|                     |
|                     |
|                     |
|                     |
|---------------------|


Try to set Full Viewport = true on the scroll view


Try adding this to your scrollview tag:

 android:fillViewport="true"

Also, you could probably have the ScrollView element be the parent object, instead of LinearLayout.


set the android:fillViewport attribute to true in your ScrollView

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


  1. Change the height of the LinearLayout inside the ScrollView to wrap_content instead of match_parent.
  2. You can't put a ListView inside a ScrollView
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜